Commit a2ec1344 by Tobin Ehlis Committed by Commit Bot

Add shared mutex to frontend

Add shared mutex to frontend API entrypoints that is only enabled when ANGLE is being used with a shared context. Bug: angleproject:2464 Change-Id: I0d918e37d9579dccd013dc88f563bed7de7ee55f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1685712Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Courtney Goeltzenleuchter <courtneygo@google.com>
parent bc0a7b58
......@@ -6,7 +6,7 @@
"scripts/entry_point_packed_gl_enums.json":
"711fe78fe4838ac5451385275605a69a",
"scripts/generate_entry_points.py":
"5650698233a9be8d4c8a5840c92a738d",
"61b57bcf1af62062abbc099c01d2fada",
"scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708",
"scripts/gl_angle_ext.xml":
......@@ -140,79 +140,79 @@
"src/libANGLE/validationGL4_autogen.h":
"ebbde7f5154a4d1736330d1fc53b3af7",
"src/libGL/entry_points_gl_1_0_autogen.cpp":
"96092a26b819623ca49a81c3690830ed",
"d78521b904e4f33d058cfbb9f955846c",
"src/libGL/entry_points_gl_1_0_autogen.h":
"a2372719bd7fbc4a6b070ecae7d9247a",
"src/libGL/entry_points_gl_1_1_autogen.cpp":
"967dd7ef4c08c140a67eb57c18a8a391",
"359d8bcd794a53beda0b01445a2d87a0",
"src/libGL/entry_points_gl_1_1_autogen.h":
"29ff203c0d402f78d020525a5e5ee447",
"src/libGL/entry_points_gl_1_2_autogen.cpp":
"627f9a4d4027b80ff6ef70165da73116",
"3ae724a3ea3d16bdaaf2d5f079eb10e8",
"src/libGL/entry_points_gl_1_2_autogen.h":
"db041e9b37eaaf1c31a4b4e2e4e987f4",
"src/libGL/entry_points_gl_1_3_autogen.cpp":
"21523304ba89513af7a80ac9630d97b2",
"4113982882328037b41390f9c8916418",
"src/libGL/entry_points_gl_1_3_autogen.h":
"0c30cbdd3d5b10e9217a049cc2794317",
"src/libGL/entry_points_gl_1_4_autogen.cpp":
"cf02087b9f49b68c79b40c613151cc07",
"44a146542f17d737fdb5a6ff840985b0",
"src/libGL/entry_points_gl_1_4_autogen.h":
"6f3dcfd98c18cd53f32e61ee01eabad6",
"src/libGL/entry_points_gl_1_5_autogen.cpp":
"c14c1660c18f40eb2ab097e7f7dcb6fe",
"5e6ad15dd05aaaae31ac27148c59d524",
"src/libGL/entry_points_gl_1_5_autogen.h":
"8caacff247caecb833b065afaf6e90ef",
"src/libGL/entry_points_gl_2_0_autogen.cpp":
"cf239b560209f34d4b8154981a4561c0",
"c396e7934bc8c2fe86cf5a1c535ca908",
"src/libGL/entry_points_gl_2_0_autogen.h":
"f0f58f83717148d58b735af5c435f2ef",
"src/libGL/entry_points_gl_2_1_autogen.cpp":
"d15c90bd58f6d20ba3dc21946c9fae09",
"2fd1e63292a28acea2e9ffece36eecfa",
"src/libGL/entry_points_gl_2_1_autogen.h":
"87cd6d513a5852c56eed9b58484fbe19",
"src/libGL/entry_points_gl_3_0_autogen.cpp":
"abe3c50306083a428fdb3bcd7445b0f2",
"c25c8d4fd7abf4232d6fd3d8ddfa032c",
"src/libGL/entry_points_gl_3_0_autogen.h":
"47396290a846f808e598acdbca56e9b3",
"src/libGL/entry_points_gl_3_1_autogen.cpp":
"0a33c5ca28297647cbadc8d66265bb7d",
"4376b64bef93c4d42e7a00be8f555eaf",
"src/libGL/entry_points_gl_3_1_autogen.h":
"6ee6613c0206d99c6afdcd3faddb52a3",
"src/libGL/entry_points_gl_3_2_autogen.cpp":
"29dcde3d2aeb3d69822e4c10673b0ecb",
"86c42d318bc89ee41172f9bbed009f0c",
"src/libGL/entry_points_gl_3_2_autogen.h":
"347e40b5c9fd08a693bf4ffe713c61e6",
"src/libGL/entry_points_gl_3_3_autogen.cpp":
"f89eec28c18b6c39ec6c3a595310a6a3",
"5ef9ed14cdfd507e421913679178ae6a",
"src/libGL/entry_points_gl_3_3_autogen.h":
"2151c64b03364111ad1455609243caba",
"src/libGL/entry_points_gl_4_0_autogen.cpp":
"f0dee9931d60318c7b106cb620af9dde",
"a96c569803d09672dbb20475e758736b",
"src/libGL/entry_points_gl_4_0_autogen.h":
"c5a258322ee6de37ffdbb6f40d5703a2",
"src/libGL/entry_points_gl_4_1_autogen.cpp":
"80a8f927cb407a58125002258845f50c",
"94688234fea1be3745294c84dc71f5ca",
"src/libGL/entry_points_gl_4_1_autogen.h":
"ea1e18bf5ed2bd1063c940bd793cb50c",
"src/libGL/entry_points_gl_4_2_autogen.cpp":
"9152cbc62d356b20d12f667249ec7dca",
"b71232b3b06df016bc4d5e38886dbfa6",
"src/libGL/entry_points_gl_4_2_autogen.h":
"e6b93e1c3028230ebf5ba8a09f5f4aca",
"src/libGL/entry_points_gl_4_3_autogen.cpp":
"6c4c5c70a93fa3ad2967d2b1c4dec2b4",
"b80d1d45566931d64686b1468213d0d0",
"src/libGL/entry_points_gl_4_3_autogen.h":
"60bf8a8337129670875de694386a0a9d",
"src/libGL/entry_points_gl_4_4_autogen.cpp":
"2f8ff25055989366a13c03b28f48544f",
"1797f4b0e6e2ad9370a133e360e0c232",
"src/libGL/entry_points_gl_4_4_autogen.h":
"d0a8c556ffb1c9d4519a66b2868c68b2",
"src/libGL/entry_points_gl_4_5_autogen.cpp":
"4df50dc44d1ee1afcfaae5e3c00c3e38",
"e16fd2c90e6c0d6abd4346425e79ff9e",
"src/libGL/entry_points_gl_4_5_autogen.h":
"0cc66bfbe40b1120e38ba977c2c95cc1",
"src/libGL/entry_points_gl_4_6_autogen.cpp":
"3823ded8b5957a1e1b84e2dae7f00bb8",
"4320353152d44e242b306ced8e41063b",
"src/libGL/entry_points_gl_4_6_autogen.h":
"d659e18d8caffa8d0729fc1a8bdd79f2",
"src/libGL/libGL_autogen.cpp":
......@@ -220,23 +220,23 @@
"src/libGL/libGL_autogen.def":
"b372327de868ff8eaa4f837b7e434f72",
"src/libGLESv2/entry_points_gles_1_0_autogen.cpp":
"9f18cbeb0767ec936bb3e63c566d05a9",
"fd74939207b2576b4295a0abc6620076",
"src/libGLESv2/entry_points_gles_1_0_autogen.h":
"77fa8d307ebf839838f8812786cddc1a",
"src/libGLESv2/entry_points_gles_2_0_autogen.cpp":
"9b596996d53c913da610ec2ee9a5e2b7",
"c361d24df4609a4869a3f3f75f8d9907",
"src/libGLESv2/entry_points_gles_2_0_autogen.h":
"3bbaf1cf42fba5d675e5b54cd1d14df7",
"src/libGLESv2/entry_points_gles_3_0_autogen.cpp":
"ef275b88896ce23ebd6ab347fc413637",
"a417370721a1a143de299568b8d4aa90",
"src/libGLESv2/entry_points_gles_3_0_autogen.h":
"395f6978219abd5182bbe80cc367e40c",
"src/libGLESv2/entry_points_gles_3_1_autogen.cpp":
"af6734b424784edaf9785c5cd6d77446",
"9029353eeb68025ff87e84d67e26f859",
"src/libGLESv2/entry_points_gles_3_1_autogen.h":
"043d09a964c740067bf4279e0b544aed",
"src/libGLESv2/entry_points_gles_ext_autogen.cpp":
"f1a9329600e5011a49d516c21f01f148",
"e7264a373a5825da16791e6cf2b3a326",
"src/libGLESv2/entry_points_gles_ext_autogen.h":
"294cc52579b3439e99914c11bb7cd9f6",
"src/libGLESv2/libGLESv2_autogen.cpp":
......
......@@ -155,6 +155,7 @@ template_entry_point_no_return = """void GL_APIENTRY {name}{explicit_context_suf
Context *context = {context_getter};
if (context)
{{{assert_explicit_context}{packed_gl_enum_conversions}
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || Validate{name}({validate_params}));
if (isCallValid)
{{
......@@ -173,6 +174,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);
bool isCallValid = (context->skipValidation() || Validate{name}({validate_params}));
if (isCallValid)
{{
......
......@@ -322,6 +322,7 @@ Context::Context(egl::Display *display,
GetClientArraysEnabled(attribs),
GetRobustResourceInit(attribs),
memoryProgramCache != nullptr),
mShared(shareContext != nullptr),
mSkipValidation(GetNoError(attribs)),
mDisplayTextureShareGroup(shareTextures != nullptr),
mErrors(this),
......
......@@ -489,6 +489,10 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
return mState.isCurrentVertexArray(va);
}
bool isShared() const { return mShared; }
// Once a context is setShared() it cannot be undone
void setShared() { mShared = true; }
const State &getState() const { return mState; }
GLint getClientMajorVersion() const { return mState.getClientMajorVersion(); }
GLint getClientMinorVersion() const { return mState.getClientMinorVersion(); }
......@@ -615,6 +619,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
void setUniform1iImpl(Program *program, GLint location, GLsizei count, const GLint *v);
State mState;
bool mShared;
bool mSkipValidation;
bool mDisplayTextureShareGroup;
......
......@@ -880,7 +880,7 @@ Error Display::createStream(const AttributeMap &attribs, Stream **outStream)
}
Error Display::createContext(const Config *configuration,
const gl::Context *shareContext,
gl::Context *shareContext,
EGLenum clientType,
const AttributeMap &attribs,
gl::Context **outContext)
......@@ -930,6 +930,10 @@ Error Display::createContext(const Config *configuration,
gl::Context *context =
new gl::Context(this, configuration, shareContext, shareTextures, cachePointer, clientType,
attribs, mDisplayExtensions, GetClientExtensions());
if (shareContext != nullptr)
{
shareContext->setShared();
}
ASSERT(context != nullptr);
mContextSet.insert(context);
......@@ -1055,8 +1059,8 @@ Error Display::destroyContext(const Thread *thread, gl::Context *context)
Surface *currentReadSurface = thread->getCurrentReadSurface();
bool changeContextForDeletion = context != currentContext;
// Make the context being deleted current during it's deletion. This allows it to delete any
// resources it's holding.
// Make the context being deleted current during it's deletion. This allows it to delete
// any resources it's holding.
if (changeContextForDeletion)
{
ANGLE_TRY(makeCurrent(thread, nullptr, nullptr, context));
......@@ -1067,8 +1071,9 @@ Error Display::destroyContext(const Thread *thread, gl::Context *context)
ASSERT(mGlobalTextureShareGroupUsers >= 1 && mTextureManager != nullptr);
if (mGlobalTextureShareGroupUsers == 1)
{
// If this is the last context using the global share group, destroy the global texture
// manager so that the textures can be destroyed while a context still exists
// If this is the last context using the global share group, destroy the global
// texture manager so that the textures can be destroyed while a context still
// exists
mTextureManager->release(context);
mTextureManager = nullptr;
}
......@@ -1296,8 +1301,8 @@ void Display::initDisplayExtensions()
// Blob cache extension is provided by the ANGLE frontend
mDisplayExtensions.blobCache = true;
// The EGL_ANDROID_recordable extension is provided by the ANGLE frontend, and will always say
// that ANativeWindow is not recordable.
// The EGL_ANDROID_recordable extension is provided by the ANGLE frontend, and will always
// say that ANativeWindow is not recordable.
mDisplayExtensions.recordable = true;
// All backends support specific context versions
......
......@@ -110,7 +110,7 @@ class Display final : public LabeledObject, angle::NonCopyable
Error createStream(const AttributeMap &attribs, Stream **outStream);
Error createContext(const Config *configuration,
const gl::Context *shareContext,
gl::Context *shareContext,
const EGLenum clientType,
const AttributeMap &attribs,
gl::Context **outContext);
......
......@@ -45,8 +45,9 @@ void GL_APIENTRY CopyTexSubImage3D(GLenum target,
Context *context = GetValidGlobalContext();
if (context)
{
TextureTarget targetPacked = FromGL<TextureTarget>(target);
bool isCallValid = (context->skipValidation() ||
TextureTarget targetPacked = FromGL<TextureTarget>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateCopyTexSubImage3D(context, targetPacked, level, xoffset,
yoffset, zoffset, x, y, width, height));
if (isCallValid)
......@@ -75,8 +76,9 @@ void GL_APIENTRY DrawRangeElements(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateDrawRangeElements(context, modePacked, start, end,
count, typePacked, indices));
......@@ -111,8 +113,9 @@ void GL_APIENTRY TexImage3D(GLenum target,
Context *context = GetValidGlobalContext();
if (context)
{
TextureTarget targetPacked = FromGL<TextureTarget>(target);
bool isCallValid = (context->skipValidation() ||
TextureTarget targetPacked = FromGL<TextureTarget>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexImage3D(context, targetPacked, level, internalformat, width,
height, depth, border, format, type, pixels));
if (isCallValid)
......@@ -148,7 +151,8 @@ void GL_APIENTRY TexSubImage3D(GLenum target,
Context *context = GetValidGlobalContext();
if (context)
{
TextureTarget targetPacked = FromGL<TextureTarget>(target);
TextureTarget targetPacked = FromGL<TextureTarget>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateTexSubImage3D(context, targetPacked, level, xoffset, yoffset, zoffset, width,
......
......@@ -39,7 +39,8 @@ void GL_APIENTRY UniformMatrix2x3fv(GLint location,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix2x3fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -62,7 +63,8 @@ void GL_APIENTRY UniformMatrix2x4fv(GLint location,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix2x4fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -85,7 +87,8 @@ void GL_APIENTRY UniformMatrix3x2fv(GLint location,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix3x2fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -108,7 +111,8 @@ void GL_APIENTRY UniformMatrix3x4fv(GLint location,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix3x4fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -131,7 +135,8 @@ void GL_APIENTRY UniformMatrix4x2fv(GLint location,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix4x2fv(context, location, count, transpose, value));
if (isCallValid)
{
......@@ -154,7 +159,8 @@ void GL_APIENTRY UniformMatrix4x3fv(GLint location,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateUniformMatrix4x3fv(context, location, count, transpose, value));
if (isCallValid)
{
......
......@@ -43,9 +43,10 @@ void GL_APIENTRY CopyBufferSubData(GLenum readTarget,
Context *context = GetValidGlobalContext();
if (context)
{
BufferBinding readTargetPacked = FromGL<BufferBinding>(readTarget);
BufferBinding writeTargetPacked = FromGL<BufferBinding>(writeTarget);
bool isCallValid = (context->skipValidation() ||
BufferBinding readTargetPacked = FromGL<BufferBinding>(readTarget);
BufferBinding writeTargetPacked = FromGL<BufferBinding>(writeTarget);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateCopyBufferSubData(context, readTargetPacked, writeTargetPacked,
readOffset, writeOffset, size));
if (isCallValid)
......@@ -66,7 +67,8 @@ void GL_APIENTRY DrawArraysInstanced(GLenum mode, GLint first, GLsizei count, GL
Context *context = GetValidGlobalContext();
if (context)
{
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateDrawArraysInstanced(context, modePacked, first, count, instancecount));
......@@ -94,9 +96,10 @@ void GL_APIENTRY DrawElementsInstanced(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
bool isCallValid = (context->skipValidation() ||
PrimitiveMode modePacked = FromGL<PrimitiveMode>(mode);
DrawElementsType typePacked = FromGL<DrawElementsType>(type);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateDrawElementsInstanced(context, modePacked, count, typePacked,
indices, instancecount));
if (isCallValid)
......@@ -122,7 +125,8 @@ void GL_APIENTRY GetActiveUniformBlockName(GLuint program,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetActiveUniformBlockName(context, program, uniformBlockIndex,
bufSize, length, uniformBlockName));
if (isCallValid)
......@@ -149,6 +153,7 @@ void GL_APIENTRY GetActiveUniformBlockiv(GLuint program,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateGetActiveUniformBlockiv(context, program, uniformBlockIndex, pname, params));
......@@ -175,7 +180,8 @@ void GL_APIENTRY GetActiveUniformName(GLuint program,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetActiveUniformName(context, program, uniformIndex, bufSize,
length, uniformName));
if (isCallValid)
......@@ -202,7 +208,8 @@ void GL_APIENTRY GetActiveUniformsiv(GLuint program,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetActiveUniformsiv(context, program, uniformCount,
uniformIndices, pname, params));
if (isCallValid)
......@@ -223,7 +230,8 @@ GLuint GL_APIENTRY GetUniformBlockIndex(GLuint program, const GLchar *uniformBlo
GLuint returnValue;
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetUniformBlockIndex(context, program, uniformBlockName));
if (isCallValid)
{
......@@ -256,6 +264,7 @@ void GL_APIENTRY GetUniformIndices(GLuint program,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateGetUniformIndices(context, program, uniformCount,
uniformNames, uniformIndices));
......@@ -275,6 +284,7 @@ void GL_APIENTRY PrimitiveRestartIndex(GLuint index)
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidatePrimitiveRestartIndex(context, index));
if (isCallValid)
......@@ -294,8 +304,9 @@ void GL_APIENTRY TexBuffer(GLenum target, GLenum internalformat, GLuint buffer)
Context *context = GetValidGlobalContext();
if (context)
{
BufferID bufferPacked = FromGL<BufferID>(buffer);
bool isCallValid = (context->skipValidation() ||
BufferID bufferPacked = FromGL<BufferID>(buffer);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexBuffer(context, target, internalformat, bufferPacked));
if (isCallValid)
{
......@@ -315,6 +326,7 @@ void GL_APIENTRY UniformBlockBinding(GLuint program,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateUniformBlockBinding(context, program, uniformBlockIndex, uniformBlockBinding));
......
......@@ -36,6 +36,7 @@ GLenum GL_APIENTRY ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeou
GLenum returnValue;
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateClientWaitSync(context, sync, flags, timeout));
if (isCallValid)
......@@ -62,6 +63,7 @@ void GL_APIENTRY DeleteSync(GLsync sync)
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateDeleteSync(context, sync));
if (isCallValid)
{
......@@ -86,6 +88,7 @@ void GL_APIENTRY DrawElementsBaseVertex(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateDrawElementsBaseVertex(context, mode, count, type, indices, basevertex));
......@@ -115,7 +118,8 @@ void GL_APIENTRY DrawElementsInstancedBaseVertex(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateDrawElementsInstancedBaseVertex(
context, mode, count, type, indices, instancecount, basevertex));
if (isCallValid)
......@@ -145,7 +149,8 @@ void GL_APIENTRY DrawRangeElementsBaseVertex(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateDrawRangeElementsBaseVertex(context, mode, start, end, count,
type, indices, basevertex));
if (isCallValid)
......@@ -168,6 +173,7 @@ GLsync GL_APIENTRY FenceSync(GLenum condition, GLbitfield flags)
GLsync returnValue;
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateFenceSync(context, condition, flags));
if (isCallValid)
......@@ -196,7 +202,8 @@ void GL_APIENTRY FramebufferTexture(GLenum target, GLenum attachment, GLuint tex
Context *context = GetValidGlobalContext();
if (context)
{
TextureID texturePacked = FromGL<TextureID>(texture);
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateFramebufferTexture(context, target, attachment, texturePacked, level));
......@@ -218,8 +225,9 @@ void GL_APIENTRY GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *pa
Context *context = GetValidGlobalContext();
if (context)
{
BufferBinding targetPacked = FromGL<BufferBinding>(target);
bool isCallValid = (context->skipValidation() ||
BufferBinding targetPacked = FromGL<BufferBinding>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetBufferParameteri64v(context, targetPacked, pname, params));
if (isCallValid)
{
......@@ -237,6 +245,7 @@ void GL_APIENTRY GetInteger64i_v(GLenum target, GLuint index, GLint64 *data)
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateGetInteger64i_v(context, target, index, data));
if (isCallValid)
......@@ -255,6 +264,7 @@ void GL_APIENTRY GetInteger64v(GLenum pname, GLint64 *data)
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateGetInteger64v(context, pname, data));
if (isCallValid)
......@@ -273,6 +283,7 @@ void GL_APIENTRY GetMultisamplefv(GLenum pname, GLuint index, GLfloat *val)
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateGetMultisamplefv(context, pname, index, val));
if (isCallValid)
......@@ -295,7 +306,8 @@ GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint *va
Context *context = GetGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateGetSynciv(context, sync, pname, bufSize, length, values));
if (isCallValid)
{
......@@ -313,6 +325,7 @@ GLboolean GL_APIENTRY IsSync(GLsync sync)
GLboolean returnValue;
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateIsSync(context, sync));
if (isCallValid)
{
......@@ -348,7 +361,8 @@ void GL_APIENTRY MultiDrawElementsBaseVertex(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateMultiDrawElementsBaseVertex(context, mode, count, type, indices,
drawcount, basevertex));
if (isCallValid)
......@@ -367,7 +381,8 @@ void GL_APIENTRY ProvokingVertex(GLenum mode)
Context *context = GetValidGlobalContext();
if (context)
{
ProvokingVertexConvention modePacked = FromGL<ProvokingVertexConvention>(mode);
ProvokingVertexConvention modePacked = FromGL<ProvokingVertexConvention>(mode);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateProvokingVertex(context, modePacked));
if (isCallValid)
......@@ -386,6 +401,7 @@ void GL_APIENTRY SampleMaski(GLuint maskNumber, GLbitfield mask)
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateSampleMaski(context, maskNumber, mask));
if (isCallValid)
......@@ -413,7 +429,8 @@ void GL_APIENTRY TexImage2DMultisample(GLenum target,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexImage2DMultisample(context, target, samples, internalformat,
width, height, fixedsamplelocations));
if (isCallValid)
......@@ -444,6 +461,7 @@ void GL_APIENTRY TexImage3DMultisample(GLenum target,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateTexImage3DMultisample(context, target, samples, internalformat, width, height,
......@@ -467,6 +485,7 @@ void GL_APIENTRY WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout)
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateWaitSync(context, sync, flags, timeout));
if (isCallValid)
......
......@@ -44,8 +44,9 @@ void GL_APIENTRY BindImageTexture(GLuint unit,
Context *context = GetValidGlobalContext();
if (context)
{
TextureID texturePacked = FromGL<TextureID>(texture);
bool isCallValid = (context->skipValidation() ||
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateBindImageTexture(context, unit, texturePacked, level, layered,
layer, access, format));
if (isCallValid)
......@@ -72,7 +73,8 @@ void GL_APIENTRY DrawArraysInstancedBaseInstance(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateDrawArraysInstancedBaseInstance(context, mode, first, count,
instancecount, baseinstance));
if (isCallValid)
......@@ -102,7 +104,8 @@ void GL_APIENTRY DrawElementsInstancedBaseInstance(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateDrawElementsInstancedBaseInstance(
context, mode, count, type, indices, instancecount, baseinstance));
if (isCallValid)
......@@ -134,6 +137,7 @@ void GL_APIENTRY DrawElementsInstancedBaseVertexBaseInstance(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateDrawElementsInstancedBaseVertexBaseInstance(
......@@ -156,6 +160,7 @@ void GL_APIENTRY DrawTransformFeedbackInstanced(GLenum mode, GLuint id, GLsizei
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateDrawTransformFeedbackInstanced(
context, mode, id, instancecount));
if (isCallValid)
......@@ -178,6 +183,7 @@ void GL_APIENTRY DrawTransformFeedbackStreamInstanced(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateDrawTransformFeedbackStreamInstanced(
context, mode, id, stream, instancecount));
......@@ -204,6 +210,7 @@ void GL_APIENTRY GetActiveAtomicCounterBufferiv(GLuint program,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateGetActiveAtomicCounterBufferiv(context, program, bufferIndex, pname, params));
......@@ -232,6 +239,7 @@ void GL_APIENTRY GetInternalformativ(GLenum target,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateGetInternalformativ(context, target, internalformat, pname, bufSize, params));
......@@ -252,6 +260,7 @@ void GL_APIENTRY MemoryBarrier(GLbitfield barriers)
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() || ValidateMemoryBarrier(context, barriers));
if (isCallValid)
{
......@@ -271,7 +280,8 @@ void GL_APIENTRY TexStorage1D(GLenum target, GLsizei levels, GLenum internalform
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexStorage1D(context, target, levels, internalformat, width));
if (isCallValid)
{
......@@ -293,7 +303,8 @@ TexStorage2D(GLenum target, GLsizei levels, GLenum internalformat, GLsizei width
Context *context = GetValidGlobalContext();
if (context)
{
TextureType targetPacked = FromGL<TextureType>(target);
TextureType targetPacked = FromGL<TextureType>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateTexStorage2D(context, targetPacked, levels, internalformat, width, height));
......@@ -322,8 +333,9 @@ void GL_APIENTRY TexStorage3D(GLenum target,
Context *context = GetValidGlobalContext();
if (context)
{
TextureType targetPacked = FromGL<TextureType>(target);
bool isCallValid = (context->skipValidation() ||
TextureType targetPacked = FromGL<TextureType>(target);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateTexStorage3D(context, targetPacked, levels, internalformat,
width, height, depth));
if (isCallValid)
......
......@@ -36,8 +36,9 @@ void GL_APIENTRY BindBuffersBase(GLenum target, GLuint first, GLsizei count, con
Context *context = GetValidGlobalContext();
if (context)
{
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
bool isCallValid = (context->skipValidation() ||
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateBindBuffersBase(context, target, first, count, buffersPacked));
if (isCallValid)
{
......@@ -64,7 +65,8 @@ void GL_APIENTRY BindBuffersRange(GLenum target,
Context *context = GetValidGlobalContext();
if (context)
{
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateBindBuffersRange(context, target, first, count,
buffersPacked, offsets, sizes));
......@@ -85,7 +87,8 @@ void GL_APIENTRY BindImageTextures(GLuint first, GLsizei count, const GLuint *te
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateBindImageTextures(context, first, count, textures));
if (isCallValid)
{
......@@ -103,6 +106,7 @@ void GL_APIENTRY BindSamplers(GLuint first, GLsizei count, const GLuint *sampler
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateBindSamplers(context, first, count, samplers));
if (isCallValid)
......@@ -121,6 +125,7 @@ void GL_APIENTRY BindTextures(GLuint first, GLsizei count, const GLuint *texture
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() || ValidateBindTextures(context, first, count, textures));
if (isCallValid)
......@@ -145,7 +150,8 @@ void GL_APIENTRY BindVertexBuffers(GLuint first,
Context *context = GetValidGlobalContext();
if (context)
{
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
const BufferID *buffersPacked = FromGL<const BufferID *>(buffers);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateBindVertexBuffers(context, first, count, buffersPacked, offsets, strides));
......@@ -169,7 +175,8 @@ void GL_APIENTRY BufferStorage(GLenum target, GLsizeiptr size, const void *data,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateBufferStorage(context, target, size, data, flags));
if (isCallValid)
{
......@@ -191,7 +198,8 @@ ClearTexImage(GLuint texture, GLint level, GLenum format, GLenum type, const voi
Context *context = GetValidGlobalContext();
if (context)
{
TextureID texturePacked = FromGL<TextureID>(texture);
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateClearTexImage(context, texturePacked, level, format, type, data));
......@@ -227,7 +235,8 @@ void GL_APIENTRY ClearTexSubImage(GLuint texture,
Context *context = GetValidGlobalContext();
if (context)
{
TextureID texturePacked = FromGL<TextureID>(texture);
TextureID texturePacked = FromGL<TextureID>(texture);
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid =
(context->skipValidation() ||
ValidateClearTexSubImage(context, texturePacked, level, xoffset, yoffset, zoffset,
......
......@@ -40,7 +40,8 @@ void GL_APIENTRY MultiDrawArraysIndirectCount(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateMultiDrawArraysIndirectCount(context, mode, indirect, drawcount,
maxdrawcount, stride));
if (isCallValid)
......@@ -68,7 +69,8 @@ void GL_APIENTRY MultiDrawElementsIndirectCount(GLenum mode,
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidateMultiDrawElementsIndirectCount(
context, mode, type, indirect, drawcount, maxdrawcount, stride));
if (isCallValid)
......@@ -88,7 +90,8 @@ void GL_APIENTRY PolygonOffsetClamp(GLfloat factor, GLfloat units, GLfloat clamp
Context *context = GetValidGlobalContext();
if (context)
{
bool isCallValid = (context->skipValidation() ||
std::unique_lock<std::mutex> shareContextLock = GetShareGroupLock(context);
bool isCallValid = (context->skipValidation() ||
ValidatePolygonOffsetClamp(context, factor, units, clamp));
if (isCallValid)
{
......@@ -113,6 +116,7 @@ void GL_APIENTRY SpecializeShader(GLuint shader,
Context *context = GetValidGlobalContext();
if (context)
{
std::unique_lock<std::mutex> 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.
......@@ -56,6 +56,11 @@ ANGLE_INLINE Context *GetValidGlobalContext()
return thread->getValidContext();
}
ANGLE_INLINE std::unique_lock<std::mutex> GetShareGroupLock(const Context *context)
{
return context->isShared() ? std::unique_lock<std::mutex>(egl::GetGlobalMutex())
: std::unique_lock<std::mutex>();
}
} // namespace gl
#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