Commit 0a6e118d by Brandon Schade Committed by Commit Bot

Change g_Mutex from std::mutex to std::recursive_mutex

When running flatland on android-10.0.0_r21 (Pixel 3), libgui's ~EglImage calls eglTerminate which grabs angle's EGL entry point mutex. The path continues to libvulkan where eventually another egl call happens (eglDestroyImageKHR) and it will attempt to take the mutex at the entry point again. So we try to get the mutex multiple times from the same thread. Change this mutex to a recursive_mutex to allow for this re-entry of EGL calls Tests: android-10.0.0_r21/frameworks/native/cmds/flatland Bug: angleproject:4354 Change-Id: If8a817df45e9f58d5f06884510350e17d7127fa9 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2029218 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent 0d224cce
......@@ -162,6 +162,7 @@ Samsung Electronics, Inc.
Kyeongmin Kim
Minkyu Jeong
Mohan Maiya
Peter Mowry
Sangwon Park
Arm Ltd.
......
......@@ -6,7 +6,7 @@
"scripts/entry_point_packed_gl_enums.json":
"bcf97f16fd4cd4d4e50d66622982e67e",
"scripts/generate_entry_points.py":
"36f89f5514fff27ecb4baeded89ae64d",
"eb3d1f20c9f1657ef2bceb16e9b72326",
"scripts/gl.xml":
"2af7b077ec347349b3a92683e8fb8b03",
"scripts/gl_angle_ext.xml":
......@@ -150,79 +150,79 @@
"src/libANGLE/validationGL4_autogen.h":
"71b13ac14f7654a19f7606cb23309551",
"src/libGL/entry_points_gl_1_0_autogen.cpp":
"bde4948820270267c355f88d4a264c10",
"e984e675dab9624214609fc86f1330a8",
"src/libGL/entry_points_gl_1_0_autogen.h":
"4ff00afc21780bc6c138b5431a2d067c",
"src/libGL/entry_points_gl_1_1_autogen.cpp":
"f8359af4500dcdb7e226ee4728c2d102",
"253205804905c1e5bf6422c1df606079",
"src/libGL/entry_points_gl_1_1_autogen.h":
"570a839bb336d8f5f83d3b50fe49411a",
"src/libGL/entry_points_gl_1_2_autogen.cpp":
"1a1272598532f37ad9012219f892d5a5",
"0ca1ad8d1a3a48c8053b4081bdf5f5e4",
"src/libGL/entry_points_gl_1_2_autogen.h":
"3f52187f299fe96672384e1646f4a1cb",
"src/libGL/entry_points_gl_1_3_autogen.cpp":
"1c2ef73fbf616d6d96b56fb8b75eacd5",
"5bce9f7bb2639a7de57e925a028039ef",
"src/libGL/entry_points_gl_1_3_autogen.h":
"5ea36d869b82a824d5f290625c4ea052",
"src/libGL/entry_points_gl_1_4_autogen.cpp":
"2376944f9e120e857306a97b1d684348",
"e799387d084ae718fe0762d48c1a40b9",
"src/libGL/entry_points_gl_1_4_autogen.h":
"2c5d31ca248507a024e4724c74283ec4",
"src/libGL/entry_points_gl_1_5_autogen.cpp":
"f6f1789edf8f4bd71bd8e70f08fef8e9",
"aaddbde89c780194ac4754f7a1177c84",
"src/libGL/entry_points_gl_1_5_autogen.h":
"978457aa9a40e427846b6dea24608903",
"src/libGL/entry_points_gl_2_0_autogen.cpp":
"66e735b584060f1eae4aea4933a1a940",
"84159251135f9ff63ab46b0d44717e8c",
"src/libGL/entry_points_gl_2_0_autogen.h":
"41b0cd064167fac84bcdb1896a275b1b",
"src/libGL/entry_points_gl_2_1_autogen.cpp":
"7e366fe38a83b7c853b70ffc94c36c79",
"fb873cf58c85b5f7bb3806723bb9cc7d",
"src/libGL/entry_points_gl_2_1_autogen.h":
"1da48dec560ea5ff8cadf4d0b6bfde1c",
"src/libGL/entry_points_gl_3_0_autogen.cpp":
"62ca2ec1da6338b7121716eb0ffb2499",
"b0f24eb8d41ed4e74f344310ae5cae58",
"src/libGL/entry_points_gl_3_0_autogen.h":
"0fad8005f23815beb8ee9b3797c00b83",
"src/libGL/entry_points_gl_3_1_autogen.cpp":
"95b0add09ab366a857c8f7f8967401aa",
"647252cbc585ec413121fe6cd16c8dbf",
"src/libGL/entry_points_gl_3_1_autogen.h":
"a68ff6c69f0ce95d9730e22bb4c63366",
"src/libGL/entry_points_gl_3_2_autogen.cpp":
"b02373cbb98e3e687b7d6287442e36ff",
"d7cddaca9a2c6e051a4dec76b03611f2",
"src/libGL/entry_points_gl_3_2_autogen.h":
"f162c4e93a64ab2e43048a0937f7c46f",
"src/libGL/entry_points_gl_3_3_autogen.cpp":
"4a61fbd2fbc5db3fc08d0f29a9a297b6",
"30f8dfd5b902d203abab84c5795e4e4b",
"src/libGL/entry_points_gl_3_3_autogen.h":
"51c0e4f074c85447f5d910c63b9ea61c",
"src/libGL/entry_points_gl_4_0_autogen.cpp":
"9a94c0f3b2261ad5e051a6a00afd7c1e",
"bd045ed365a4221b687a5165ed19ebd1",
"src/libGL/entry_points_gl_4_0_autogen.h":
"35d611138951cebc29db99c9bf3a9e5f",
"src/libGL/entry_points_gl_4_1_autogen.cpp":
"87b8a35b2196e4068db4420ba83c3eaa",
"3e222566ead25c7502759f9791e046a7",
"src/libGL/entry_points_gl_4_1_autogen.h":
"beec6659a3a77695dad66df90717c6ba",
"src/libGL/entry_points_gl_4_2_autogen.cpp":
"ed3068288540e1f42ea45cd93675b6e3",
"048be315948850676439b43fbc215d80",
"src/libGL/entry_points_gl_4_2_autogen.h":
"a2cb2a48cceaf6131f96bf8ec556aa55",
"src/libGL/entry_points_gl_4_3_autogen.cpp":
"be155d2ba7106dc6b3ba986c83cd6973",
"7201a2e9773d607756ffcd1e3a0f14f5",
"src/libGL/entry_points_gl_4_3_autogen.h":
"abfa431742a2b643db21220944e10ab0",
"src/libGL/entry_points_gl_4_4_autogen.cpp":
"041f8db5b1dd89ea7e0db77e04818f17",
"cb8e53abee5240a9b21261ece4245344",
"src/libGL/entry_points_gl_4_4_autogen.h":
"cdf1651f00d26db547b153afc09acc1c",
"src/libGL/entry_points_gl_4_5_autogen.cpp":
"0404c9d1437edb600bfbf0bef355c594",
"edcdb0812eb93bb326206ed36e926fd2",
"src/libGL/entry_points_gl_4_5_autogen.h":
"9f5de9513c06b82aca60856860f7b716",
"src/libGL/entry_points_gl_4_6_autogen.cpp":
"188f7986c5a16392f8745b2e94606f56",
"a007b9c5e0b5c445adf64e9f00ab7092",
"src/libGL/entry_points_gl_4_6_autogen.h":
"ee3150d4a8d267271a02e38e8feb923a",
"src/libGL/libGL_autogen.cpp":
......@@ -230,27 +230,27 @@
"src/libGL/libGL_autogen.def":
"2789d87b05eea9f53d52e2aff499b785",
"src/libGLESv2/entry_points_gles_1_0_autogen.cpp":
"93c57b5c9c5dce0e521ad68e2c5601f8",
"9047ef2452a45c86c4a92b568f6877c3",
"src/libGLESv2/entry_points_gles_1_0_autogen.h":
"899dcff9383465380f94fbdfe5bcf0a0",
"src/libGLESv2/entry_points_gles_2_0_autogen.cpp":
"24a8838e45538fd871b5f77f6899b65d",
"6691602981aa499d9f161fad9e29dc97",
"src/libGLESv2/entry_points_gles_2_0_autogen.h":
"26387e27cbddf5e34d6cd9f850cb8b64",
"src/libGLESv2/entry_points_gles_3_0_autogen.cpp":
"c379bd51249ab90e9c2138d0a471dc73",
"ef0c7e4e95e4a24df1a5444e73bd9546",
"src/libGLESv2/entry_points_gles_3_0_autogen.h":
"0d246024379fbf55b87204db5d6a37e3",
"src/libGLESv2/entry_points_gles_3_1_autogen.cpp":
"ae80a4410a1d53e9f0cfc1ca181466ce",
"25e9c5b7fe2ff636900b58bcc85d988e",
"src/libGLESv2/entry_points_gles_3_1_autogen.h":
"69bae5c94ed4665836a8464b6c353f9a",
"src/libGLESv2/entry_points_gles_3_2_autogen.cpp":
"9708fc119f66d89bee1352f90a098824",
"af1667dfdb02f265ff1cee8d3631081c",
"src/libGLESv2/entry_points_gles_3_2_autogen.h":
"5798aa0a73af1d4ba5dfe99b6217a247",
"src/libGLESv2/entry_points_gles_ext_autogen.cpp":
"9f598172ffb8b18f376af97a02aaf455",
"f53751a882a30cbf6d08156ba56dcd15",
"src/libGLESv2/entry_points_gles_ext_autogen.h":
"6cd7104749bf62e5dcab936c18c0b142",
"src/libGLESv2/libGLESv2_autogen.cpp":
......
......@@ -149,7 +149,7 @@ template_entry_point_no_return = """void GL_APIENTRY {name}{explicit_context_suf
if (context)
{{{assert_explicit_context}{packed_gl_enum_conversions}
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || Validate{name}({validate_params}));
if (isCallValid)
{{
......@@ -168,7 +168,7 @@ template_entry_point_with_return = """{return_type}GL_APIENTRY {name}{explicit_c
{return_type} returnValue;
if (context)
{{{assert_explicit_context}{packed_gl_enum_conversions}
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || Validate{name}({validate_params}));
if (isCallValid)
{{
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -47,9 +47,9 @@ void GL_APIENTRY CopyTexSubImage3D(GLenum target,
if (context)
{
TextureTarget targetPacked = FromGL<TextureTarget>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
TextureTarget targetPacked = FromGL<TextureTarget>(target);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateCopyTexSubImage3D(context, targetPacked, level, xoffset,
yoffset, zoffset, x, y, width, height));
if (isCallValid)
......@@ -78,9 +78,9 @@ void GL_APIENTRY DrawRangeElements(GLenum mode,
if (context)
{
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateDrawRangeElements(context, modePacked, start, end,
count, typePacked, indices));
......@@ -115,9 +115,9 @@ void GL_APIENTRY TexImage3D(GLenum target,
if (context)
{
TextureTarget targetPacked = FromGL<TextureTarget>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
TextureTarget targetPacked = FromGL<TextureTarget>(target);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexImage3D(context, targetPacked, level, internalformat, width,
height, depth, border, format, type, pixels));
if (isCallValid)
......@@ -153,8 +153,8 @@ void GL_APIENTRY TexSubImage3D(GLenum target,
if (context)
{
TextureTarget targetPacked = FromGL<TextureTarget>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
TextureTarget targetPacked = FromGL<TextureTarget>(target);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateTexSubImage3D(context, targetPacked, level, xoffset, yoffset, zoffset, width,
......
......@@ -40,8 +40,8 @@ void GL_APIENTRY UniformMatrix2x3fv(GLint location,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix2x3fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -64,8 +64,8 @@ void GL_APIENTRY UniformMatrix2x4fv(GLint location,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix2x4fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -88,8 +88,8 @@ void GL_APIENTRY UniformMatrix3x2fv(GLint location,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix3x2fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -112,8 +112,8 @@ void GL_APIENTRY UniformMatrix3x4fv(GLint location,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix3x4fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -136,8 +136,8 @@ void GL_APIENTRY UniformMatrix4x2fv(GLint location,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix4x2fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -160,8 +160,8 @@ void GL_APIENTRY UniformMatrix4x3fv(GLint location,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix4x3fv(context, location, count, transpose, value));
if (isCallValid)
{
......
......@@ -44,10 +44,10 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget,
if (context)
{
BufferBinding readTargetPacked = FromGL<BufferBinding>(readTarget);
BufferBinding writeTargetPacked = FromGL<BufferBinding>(writeTarget);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
BufferBinding readTargetPacked = FromGL<BufferBinding>(readTarget);
BufferBinding writeTargetPacked = FromGL<BufferBinding>(writeTarget);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateCopyBufferSubData(context, readTargetPacked, writeTargetPacked,
readOffset, writeOffset, size));
if (isCallValid)
......@@ -71,8 +71,8 @@ void GL_APIENTRY DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GL
if (context)
{
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateDrawArraysInstanced(context, modePacked, first, count, instancecount));
......@@ -100,10 +100,10 @@ void GL_APIENTRY DrawElementsInstanced(GLenum mode,
if (context)
{
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateDrawElementsInstanced(context, modePacked, count, typePacked,
indices, instancecount));
if (isCallValid)
......@@ -130,8 +130,8 @@ void GL_APIENTRY GetActiveUniformBlockName(GLuint program,
if (context)
{
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateGetActiveUniformBlockName(context, programPacked, uniformBlockIndex, bufSize,
......@@ -160,9 +160,9 @@ void GL_APIENTRY GetActiveUniformBlockiv(GLuint program,
if (context)
{
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetActiveUniformBlockiv(context, programPacked,
uniformBlockIndex, pname, params));
if (isCallValid)
......@@ -188,9 +188,9 @@ void GL_APIENTRY GetActiveUniformName(GLuint program,
if (context)
{
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetActiveUniformName(context, programPacked, uniformIndex,
bufSize, length, uniformName));
if (isCallValid)
......@@ -219,9 +219,9 @@ void GL_APIENTRY GetActiveUniformsiv(GLuint program,
if (context)
{
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetActiveUniformsiv(context, programPacked, uniformCount,
uniformIndices, pname, params));
if (isCallValid)
......@@ -244,9 +244,9 @@ GLuint GL_APIENTRY GetUniformBlockIndex(GLuint program, const GLchar *uniformBlo
GLuint returnValue;
if (context)
{
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetUniformBlockIndex(context, programPacked, uniformBlockName));
if (isCallValid)
{
......@@ -279,9 +279,9 @@ void GL_APIENTRY GetUniformIndices(GLuint program,
if (context)
{
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetUniformIndices(context, programPacked, uniformCount,
uniformNames, uniformIndices));
if (isCallValid)
......@@ -300,7 +300,7 @@ void GL_APIENTRY PrimitiveRestartIndex(GLuint index)
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidatePrimitiveRestartIndex(context, index));
if (isCallValid)
......@@ -321,9 +321,9 @@ void GL_APIENTRY TexBuffer(GLenum target, GLenum internalformat, GLuint buffer)
if (context)
{
BufferID bufferPacked = FromGL<BufferID>(buffer);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
BufferID bufferPacked = FromGL<BufferID>(buffer);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexBuffer(context, target, internalformat, bufferPacked));
if (isCallValid)
{
......@@ -345,9 +345,9 @@ void GL_APIENTRY UniformBlockBinding(GLuint program,
if (context)
{
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformBlockBinding(context, programPacked, uniformBlockIndex,
uniformBlockBinding));
if (isCallValid)
......
......@@ -45,9 +45,9 @@ void GL_APIENTRY BindImageTexture(GLuint unit,
if (context)
{
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateBindImageTexture(context, unit, texturePacked, level, layered,
layer, access, format));
if (isCallValid)
......@@ -74,9 +74,9 @@ void GL_APIENTRY DrawArraysInstancedBaseInstance(GLenum mode,
if (context)
{
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateDrawArraysInstancedBaseInstance(
context, modePacked, first, count, instancecount, baseinstance));
if (isCallValid)
......@@ -106,8 +106,8 @@ void GL_APIENTRY DrawElementsInstancedBaseInstance(GLenum mode,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateDrawElementsInstancedBaseInstance(
context, mode, count, type, indices, instancecount, baseinstance));
if (isCallValid)
......@@ -139,9 +139,9 @@ void GL_APIENTRY DrawElementsInstancedBaseVertexBaseInstance(GLenum mode,
if (context)
{
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateDrawElementsInstancedBaseVertexBaseInstance(
context, modePacked, count, typePacked, indices,
......@@ -165,8 +165,8 @@ void GL_APIENTRY DrawTransformFeedbackInstanced(GLenum mode, GLuint id, GLsizei
if (context)
{
TransformFeedbackID idPacked = FromGL<TransformFeedbackID>(id);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
TransformFeedbackID idPacked = FromGL<TransformFeedbackID>(id);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateDrawTransformFeedbackInstanced(context, mode, idPacked, instancecount));
......@@ -193,8 +193,8 @@ void GL_APIENTRY DrawTransformFeedbackStreamInstanced(GLenum mode,
if (context)
{
TransformFeedbackID idPacked = FromGL<TransformFeedbackID>(id);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
TransformFeedbackID idPacked = FromGL<TransformFeedbackID>(id);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateDrawTransformFeedbackStreamInstanced(
context, mode, idPacked, stream, instancecount));
......@@ -221,8 +221,8 @@ void GL_APIENTRY GetActiveAtomicCounterBufferiv(GLuint program,
if (context)
{
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
ShaderProgramID programPacked = FromGL<ShaderProgramID>(program);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateGetActiveAtomicCounterBufferiv(
context, programPacked, bufferIndex, pname, params));
......@@ -251,7 +251,7 @@ void GL_APIENTRY GetInternalformativ(GLenum target,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateGetInternalformativ(context, target, internalformat, pname, bufSize, params));
......@@ -272,7 +272,7 @@ void GL_APIENTRY MemoryBarrier(GLbitfield barriers)
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateMemoryBarrier(context, barriers));
if (isCallValid)
{
......@@ -293,8 +293,8 @@ void GL_APIENTRY TexStorage1D(GLenum target, GLsizei levels, GLenum internalform
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexStorage1D(context, target, levels, internalformat, width));
if (isCallValid)
{
......@@ -316,8 +316,8 @@ TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width
if (context)
{
TextureType targetPacked = FromGL<TextureType>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
TextureType targetPacked = FromGL<TextureType>(target);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateTexStorage2D(context, targetPacked, levels, internalformat, width, height));
......@@ -346,9 +346,9 @@ void GL_APIENTRY TexStorage3D(GLenum target,
if (context)
{
TextureType targetPacked = FromGL<TextureType>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
TextureType targetPacked = FromGL<TextureType>(target);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexStorage3D(context, targetPacked, levels, internalformat,
width, height, depth));
if (isCallValid)
......
......@@ -38,9 +38,9 @@ void GL_APIENTRY BindBuffersBase(GLenum target, GLuint first, GLsizei count, con
if (context)
{
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateBindBuffersBase(context, target, first, count, buffersPacked));
if (isCallValid)
{
......@@ -67,8 +67,8 @@ void GL_APIENTRY BindBuffersRange(GLenum target,
if (context)
{
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateBindBuffersRange(context, target, first, count,
buffersPacked, offsets, sizes));
......@@ -91,8 +91,8 @@ void GL_APIENTRY BindImageTextures(GLuint first, GLsizei count, const GLuint *te
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateBindImageTextures(context, first, count, textures));
if (isCallValid)
{
......@@ -112,7 +112,7 @@ void GL_APIENTRY BindSamplers(GLuint first, GLsizei count, const GLuint *sampler
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateBindSamplers(context, first, count, samplers));
if (isCallValid)
......@@ -133,7 +133,7 @@ void GL_APIENTRY BindTextures(GLuint first, GLsizei count, const GLuint *texture
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateBindTextures(context, first, count, textures));
if (isCallValid)
......@@ -159,8 +159,8 @@ void GL_APIENTRY BindVertexBuffers(GLuint first,
if (context)
{
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateBindVertexBuffers(context, first, count, buffersPacked, offsets, strides));
......@@ -185,8 +185,8 @@ void GL_APIENTRY BufferStorage(GLenum target, GLsizeiptr size, const void *data,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateBufferStorage(context, target, size, data, flags));
if (isCallValid)
{
......@@ -208,8 +208,8 @@ ClearTexImage(GLuint texture, GLint level, GLenum format, GLenum type, const voi
if (context)
{
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateClearTexImage(context, texturePacked, level, format, type, data));
......@@ -245,8 +245,8 @@ void GL_APIENTRY ClearTexSubImage(GLuint texture,
if (context)
{
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateClearTexSubImage(context, texturePacked, level, xoffset, yoffset, zoffset,
......
......@@ -42,8 +42,8 @@ void GL_APIENTRY MultiDrawArraysIndirectCount(GLenum mode,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateMultiDrawArraysIndirectCount(context, mode, indirect, drawcount,
maxdrawcount, stride));
if (isCallValid)
......@@ -72,8 +72,8 @@ void GL_APIENTRY MultiDrawElementsIndirectCount(GLenum mode,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateMultiDrawElementsIndirectCount(
context, mode, type, indirect, drawcount, maxdrawcount, stride));
if (isCallValid)
......@@ -95,8 +95,8 @@ void GL_APIENTRY PolygonOffsetClamp(GLfloat factor, GLfloat units, GLfloat clamp
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidatePolygonOffsetClamp(context, factor, units, clamp));
if (isCallValid)
{
......@@ -122,7 +122,7 @@ void GL_APIENTRY SpecializeShader(GLuint shader,
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
std::unique_lock<angle::GlobalMutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateSpecializeShader(context, shader, pEntryPoint, numSpecializationConstants,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -40,7 +40,7 @@ namespace
static TLSIndex threadTLS = TLS_INVALID_INDEX;
Debug *g_Debug = nullptr;
ANGLE_REQUIRE_CONSTANT_INIT std::atomic<std::mutex *> g_Mutex(nullptr);
ANGLE_REQUIRE_CONSTANT_INIT std::atomic<angle::GlobalMutex *> g_Mutex(nullptr);
static_assert(std::is_trivially_destructible<decltype(g_Mutex)>::value,
"global mutex is not trivially destructible");
......@@ -75,8 +75,8 @@ void AllocateMutex()
{
if (g_Mutex == nullptr)
{
std::unique_ptr<std::mutex> newMutex(new std::mutex());
std::mutex *expected = nullptr;
std::unique_ptr<angle::GlobalMutex> newMutex(new angle::GlobalMutex());
angle::GlobalMutex *expected = nullptr;
if (g_Mutex.compare_exchange_strong(expected, newMutex.get()))
{
newMutex.release();
......@@ -86,7 +86,7 @@ void AllocateMutex()
} // anonymous namespace
std::mutex &GetGlobalMutex()
angle::GlobalMutex &GetGlobalMutex()
{
AllocateMutex();
return *g_Mutex;
......@@ -157,10 +157,10 @@ void DeallocateDebug()
void DeallocateMutex()
{
std::mutex *mutex = g_Mutex.exchange(nullptr);
angle::GlobalMutex *mutex = g_Mutex.exchange(nullptr);
{
// Wait for the mutex to become released by other threads before deleting.
std::lock_guard<std::mutex> lock(*mutex);
std::lock_guard<angle::GlobalMutex> lock(*mutex);
}
SafeDelete(mutex);
}
......
......@@ -16,19 +16,24 @@
#include <mutex>
namespace angle
{
using GlobalMutex = std::recursive_mutex;
} // namespace angle
namespace egl
{
class Debug;
class Thread;
std::mutex &GetGlobalMutex();
angle::GlobalMutex &GetGlobalMutex();
Thread *GetCurrentThread();
Debug *GetDebug();
void SetContextCurrent(Thread *thread, gl::Context *context);
} // namespace egl
#define ANGLE_SCOPED_GLOBAL_LOCK() \
std::lock_guard<std::mutex> globalMutexLock(egl::GetGlobalMutex())
std::lock_guard<angle::GlobalMutex> globalMutexLock(egl::GetGlobalMutex())
namespace gl
{
......@@ -56,10 +61,10 @@ ANGLE_INLINE Context *GetValidGlobalContext()
return thread->getValidContext();
}
ANGLE_INLINE std::unique_lock<std::mutex> GetShareGroupLock(const Context *context)
ANGLE_INLINE std::unique_lock<angle::GlobalMutex> GetShareGroupLock(const Context *context)
{
return context->isShared() ? std::unique_lock<std::mutex>(egl::GetGlobalMutex())
: std::unique_lock<std::mutex>();
return context->isShared() ? std::unique_lock<angle::GlobalMutex>(egl::GetGlobalMutex())
: std::unique_lock<angle::GlobalMutex>();
}
} // namespace gl
......
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