dEQP-GLES31.functional.debug.state_query.debug_group_stack_depth_*
tries to call glGet on GL_DEBUG_GROUP_STACK_DEPTH right away, before
doing any other debug setup. This should return 1.
However, because ctx->Debug wasn't allocated, we bailed and returned 0.
This patch removes the open-coded locking and switches the two glGet
functions to use _mesa_lock_debug_state(), which takes care of
allocating and initializing that state on the first time. It also
conveniently takes care of unlocking on failure for us, so we don't
need to handle that in every caller.
Fixes dEQP-GLES31.functional.debug.state_query.debug_group_stack_depth_
{getboolean,getfloat,getinteger,getinteger64}.
Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
GLint
_mesa_get_debug_state_int(struct gl_context *ctx, GLenum pname)
{
- struct gl_debug_state *debug;
GLint val;
- mtx_lock(&ctx->DebugMutex);
- debug = ctx->Debug;
- if (!debug) {
- mtx_unlock(&ctx->DebugMutex);
+ struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
+ if (!debug)
return 0;
- }
switch (pname) {
case GL_DEBUG_OUTPUT:
break;
}
- mtx_unlock(&ctx->DebugMutex);
+ _mesa_unlock_debug_state(ctx);
return val;
}
void *
_mesa_get_debug_state_ptr(struct gl_context *ctx, GLenum pname)
{
- struct gl_debug_state *debug;
void *val;
+ struct gl_debug_state *debug = _mesa_lock_debug_state(ctx);
- mtx_lock(&ctx->DebugMutex);
- debug = ctx->Debug;
- if (!debug) {
- mtx_unlock(&ctx->DebugMutex);
+ if (!debug)
return NULL;
- }
switch (pname) {
case GL_DEBUG_CALLBACK_FUNCTION_ARB:
break;
}
- mtx_unlock(&ctx->DebugMutex);
+ _mesa_unlock_debug_state(ctx);
return val;
}