diff --git a/src/mapi/glapi/gen/gl_API.xml b/src/mapi/glapi/gen/gl_API.xml
index bffb0723287..ce737453585 100644
--- a/src/mapi/glapi/gen/gl_API.xml
+++ b/src/mapi/glapi/gen/gl_API.xml
@@ -1155,7 +1155,8 @@
-
+
@@ -1369,7 +1370,8 @@
-
+
diff --git a/src/mesa/main/glthread.h b/src/mesa/main/glthread.h
index de9783443b0..6ed17a3c69d 100644
--- a/src/mesa/main/glthread.h
+++ b/src/mesa/main/glthread.h
@@ -154,6 +154,7 @@ struct glthread_state
/** Whether GLThread is enabled. */
bool enabled;
+ bool inside_begin_end;
/** Display lists. */
GLenum ListMode; /**< Zero if not inside display list, else list mode. */
diff --git a/src/mesa/main/glthread_get.c b/src/mesa/main/glthread_get.c
index 2c85d605ef9..916f9b3a49b 100644
--- a/src/mesa/main/glthread_get.c
+++ b/src/mesa/main/glthread_get.c
@@ -38,6 +38,10 @@ _mesa_marshal_GetIntegerv(GLenum pname, GLint *p)
{
GET_CURRENT_CONTEXT(ctx);
+ /* This will generate GL_INVALID_OPERATION, as it should. */
+ if (ctx->GLThread.inside_begin_end)
+ goto sync;
+
/* TODO: Use get_hash_params.py to return values for items containing:
* - CONST(
* - CONTEXT_[A-Z]*(Const
@@ -127,6 +131,7 @@ _mesa_marshal_GetIntegerv(GLenum pname, GLint *p)
return;
}
+sync:
_mesa_glthread_finish_before(ctx, "GetIntegerv");
CALL_GetIntegerv(ctx->CurrentServerDispatch, (pname, p));
}
diff --git a/src/mesa/main/glthread_marshal.h b/src/mesa/main/glthread_marshal.h
index 2db4be1a28b..9c56e57e78c 100644
--- a/src/mesa/main/glthread_marshal.h
+++ b/src/mesa/main/glthread_marshal.h
@@ -487,6 +487,10 @@ _mesa_glthread_Disable(struct gl_context *ctx, GLenum cap)
static inline int
_mesa_glthread_IsEnabled(struct gl_context *ctx, GLenum cap)
{
+ /* This will generate GL_INVALID_OPERATION, as it should. */
+ if (ctx->GLThread.inside_begin_end)
+ return -1;
+
switch (cap) {
case GL_CULL_FACE:
return ctx->GLThread.CullFace;
diff --git a/src/mesa/main/glthread_shaderobj.c b/src/mesa/main/glthread_shaderobj.c
index 3fd5bbdcefc..617f10fb590 100644
--- a/src/mesa/main/glthread_shaderobj.c
+++ b/src/mesa/main/glthread_shaderobj.c
@@ -155,6 +155,15 @@ _mesa_marshal_GetActiveUniform(GLuint program, GLuint index, GLsizei bufSize,
{
GET_CURRENT_CONTEXT(ctx);
+ /* This will generate GL_INVALID_OPERATION, as it should. */
+ if (ctx->GLThread.inside_begin_end) {
+ _mesa_glthread_finish_before(ctx, "GetActiveUniform");
+ CALL_GetActiveUniform(ctx->CurrentServerDispatch,
+ (program, index, bufSize, length, size, type,
+ name));
+ return;
+ }
+
wait_for_glLinkProgram(ctx);
/* We can execute glGetActiveUniform without syncing if we are sync'd to
@@ -182,6 +191,12 @@ _mesa_marshal_GetUniformLocation(GLuint program, const GLchar *name)
{
GET_CURRENT_CONTEXT(ctx);
+ /* This will generate GL_INVALID_OPERATION, as it should. */
+ if (ctx->GLThread.inside_begin_end) {
+ _mesa_glthread_finish_before(ctx, "GetUniformLocation");
+ return CALL_GetUniformLocation(ctx->CurrentServerDispatch, (program, name));
+ }
+
wait_for_glLinkProgram(ctx);
/* This is thread-safe. See the comment in _mesa_marshal_GetActiveUniform. */