Fix GL resource access thread safety
Add resource manager lock, and ContextPtr to automatically take it
Affects: Everything, dEQP-EGL.functional.sharing.gles2.multithread.*
Bug: b/112184433
Change-Id: Ifdc5b18c738f92bbab08217f672a8ed6093e1672
Reviewed-on: https://swiftshader-review.googlesource.com/20388
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
diff --git a/src/OpenGL/libGLESv2/libGLESv3.cpp b/src/OpenGL/libGLESv2/libGLESv3.cpp
index b4f5377..709c129 100644
--- a/src/OpenGL/libGLESv2/libGLESv3.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv3.cpp
@@ -214,7 +214,7 @@
{
TRACE("(GLenum src = 0x%X)", src);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -318,7 +318,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -364,7 +364,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -418,7 +418,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -465,7 +465,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -539,7 +539,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -626,7 +626,7 @@
break;
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -666,7 +666,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -686,7 +686,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -706,7 +706,7 @@
return GL_FALSE;
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -735,7 +735,7 @@
return error(GL_INVALID_OPERATION);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -752,7 +752,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -770,7 +770,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -792,7 +792,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -826,7 +826,7 @@
{
TRACE("(GLenum target = 0x%X)", target);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -864,7 +864,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -893,7 +893,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -985,7 +985,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1017,7 +1017,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1049,7 +1049,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1081,7 +1081,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1113,7 +1113,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1145,7 +1145,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1194,7 +1194,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1222,7 +1222,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1370,7 +1370,7 @@
return error(GL_INVALID_OPERATION, nullptr);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1424,7 +1424,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1466,7 +1466,7 @@
{
TRACE("(GLuint array = %d)", array);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1493,7 +1493,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1518,7 +1518,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1543,7 +1543,7 @@
return GL_FALSE;
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1568,7 +1568,7 @@
TRACE("(GLenum target = 0x%X, GLuint index = %d, GLint* data = %p)",
target, index, data);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1637,7 +1637,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1662,7 +1662,7 @@
{
TRACE("()");
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1693,7 +1693,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1734,7 +1734,7 @@
TRACE("(GLenum target = 0x%X, GLuint index = %d, GLuint buffer = %d)",
target, index, buffer);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1780,7 +1780,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1805,7 +1805,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1853,7 +1853,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1874,7 +1874,7 @@
TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLint *params = %p)",
index, pname, params);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1930,7 +1930,7 @@
TRACE("(GLuint index = %d, GLenum pname = 0x%X, GLuint *params = %p)",
index, pname, params);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -1991,7 +1991,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2010,7 +2010,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2028,7 +2028,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2045,7 +2045,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2058,7 +2058,7 @@
TRACE("(GLuint program = %d, GLint location = %d, GLuint *params = %p)",
program, location, params);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2092,7 +2092,7 @@
{
TRACE("(GLuint program = %d, const GLchar *name = %p)", program, name);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2157,7 +2157,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2190,7 +2190,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2223,7 +2223,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2256,7 +2256,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2284,7 +2284,7 @@
TRACE("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLint *value = %p)",
buffer, drawbuffer, value);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2321,7 +2321,7 @@
TRACE("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLuint *value = %p)",
buffer, drawbuffer, value);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2348,7 +2348,7 @@
TRACE("(GLenum buffer = 0x%X, GLint drawbuffer = %d, const GLfloat *value = %p)",
buffer, drawbuffer, value);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2385,7 +2385,7 @@
TRACE("(GLenum buffer = 0x%X, GLint drawbuffer = %d, GLfloat depth = %f, GLint stencil = %d)",
buffer, drawbuffer, depth, stencil);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2412,7 +2412,7 @@
{
TRACE("(GLenum name = 0x%X, GLuint index = %d)", name, index);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
GLuint numExtensions;
@@ -2445,7 +2445,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2488,7 +2488,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2548,7 +2548,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2589,7 +2589,7 @@
TRACE("(GLuint program = %d, const GLchar *uniformBlockName = %p)",
program, uniformBlockName);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2618,7 +2618,7 @@
TRACE("(GLuint program = %d, GLuint uniformBlockIndex = %d, GLenum pname = 0x%X, GLint *params = %p)",
program, uniformBlockIndex, pname, params);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2663,7 +2663,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2693,7 +2693,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2737,7 +2737,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2785,7 +2785,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2816,7 +2816,7 @@
return error(GL_INVALID_VALUE, nullptr);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2830,7 +2830,7 @@
{
TRACE("(GLsync sync = %p)", sync);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2854,7 +2854,7 @@
return;
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2876,7 +2876,7 @@
return error(GL_INVALID_VALUE, GL_FALSE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2909,7 +2909,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2930,7 +2930,7 @@
{
TRACE("(GLenum pname = 0x%X, GLint64 *data = %p)", pname, data);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -2993,7 +2993,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3011,7 +3011,7 @@
{
TRACE("(GLenum target = 0x%X, GLuint index = %d, GLint64 *data = %p)", target, index, data);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3070,7 +3070,7 @@
{
TRACE("(GLenum target = 0x%X, GLenum pname = 0x%X, GLint64 *params = %p)", target, pname, params);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3122,7 +3122,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3142,7 +3142,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3162,7 +3162,7 @@
return GL_FALSE;
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3184,7 +3184,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3220,7 +3220,7 @@
return;
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3251,7 +3251,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3277,7 +3277,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3300,7 +3300,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3317,7 +3317,7 @@
{
TRACE("(GLuint index = %d, GLuint divisor = %d)", index, divisor);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3339,7 +3339,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3368,7 +3368,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3398,7 +3398,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3418,7 +3418,7 @@
return GL_FALSE;
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3437,7 +3437,7 @@
{
TRACE("()");
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3458,7 +3458,7 @@
{
TRACE("()");
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3485,7 +3485,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3511,7 +3511,7 @@
return error(GL_INVALID_VALUE);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3532,7 +3532,7 @@
TRACE("(GLuint program = %d, GLenum pname = 0x%X, GLint value = %d)",
program, pname, value);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3571,7 +3571,7 @@
TRACE("(GLenum target = 0x%X, GLsizei numAttachments = %d, const GLenum *attachments = %p, GLint x = %d, GLint y = %d, GLsizei width = %d, GLsizei height = %d)",
target, numAttachments, attachments, x, y, width, height);
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3655,7 +3655,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{
@@ -3737,7 +3737,7 @@
return error(GL_INVALID_ENUM);
}
- es2::Context *context = es2::getContext();
+ auto context = es2::getContext();
if(context)
{