mesa/st: migrate debug callback code into mesa
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14632>
This commit is contained in:
parent
bc122e0769
commit
84fe99b2a0
|
@ -37,6 +37,7 @@
|
|||
#include "util/u_memory.h"
|
||||
#include "api_exec_decl.h"
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
|
||||
static GLuint PrevDynamicID = 0;
|
||||
|
||||
|
@ -680,6 +681,83 @@ debug_pop_group(struct gl_debug_state *debug)
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Installed as pipe_debug_callback when GL_DEBUG_OUTPUT is enabled.
|
||||
*/
|
||||
static void
|
||||
_debug_message(void *data,
|
||||
unsigned *id,
|
||||
enum pipe_debug_type ptype,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
struct gl_context *ctx = data;
|
||||
enum mesa_debug_source source;
|
||||
enum mesa_debug_type type;
|
||||
enum mesa_debug_severity severity;
|
||||
|
||||
switch (ptype) {
|
||||
case PIPE_DEBUG_TYPE_OUT_OF_MEMORY:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_ERROR;
|
||||
severity = MESA_DEBUG_SEVERITY_MEDIUM;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_ERROR:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_ERROR;
|
||||
severity = MESA_DEBUG_SEVERITY_MEDIUM;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_SHADER_INFO:
|
||||
source = MESA_DEBUG_SOURCE_SHADER_COMPILER;
|
||||
type = MESA_DEBUG_TYPE_OTHER;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_PERF_INFO:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_PERFORMANCE;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_INFO:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_OTHER;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_FALLBACK:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_PERFORMANCE;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_CONFORMANCE:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_OTHER;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
default:
|
||||
unreachable("invalid debug type");
|
||||
}
|
||||
_mesa_gl_vdebugf(ctx, id, source, type, severity, fmt, args);
|
||||
}
|
||||
|
||||
void
|
||||
_mesa_update_debug_callback(struct gl_context *ctx)
|
||||
{
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
|
||||
if (!pipe->set_debug_callback)
|
||||
return;
|
||||
|
||||
if (_mesa_get_debug_state_int(ctx, GL_DEBUG_OUTPUT)) {
|
||||
struct pipe_debug_callback cb;
|
||||
memset(&cb, 0, sizeof(cb));
|
||||
cb.async = !_mesa_get_debug_state_int(ctx, GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
cb.debug_message = _debug_message;
|
||||
cb.data = ctx;
|
||||
pipe->set_debug_callback(pipe, &cb);
|
||||
} else {
|
||||
pipe->set_debug_callback(pipe, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lock and return debug state for the context. The debug state will be
|
||||
* allocated and initialized upon the first call. When NULL is returned, the
|
||||
|
|
|
@ -69,6 +69,9 @@ _mesa_debug_is_message_enabled(const struct gl_debug_state *debug,
|
|||
GLuint id,
|
||||
enum mesa_debug_severity severity);
|
||||
|
||||
void
|
||||
_mesa_update_debug_callback(struct gl_context *ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -79,7 +79,7 @@ st_Enable(struct gl_context *ctx, GLenum cap)
|
|||
switch (cap) {
|
||||
case GL_DEBUG_OUTPUT:
|
||||
case GL_DEBUG_OUTPUT_SYNCHRONOUS:
|
||||
st_update_debug_callback(ctx);
|
||||
_mesa_update_debug_callback(ctx);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -63,81 +63,3 @@ st_debug_init(void)
|
|||
{
|
||||
ST_DEBUG = debug_get_option_st_debug();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Installed as pipe_debug_callback when GL_DEBUG_OUTPUT is enabled.
|
||||
*/
|
||||
static void
|
||||
st_debug_message(void *data,
|
||||
unsigned *id,
|
||||
enum pipe_debug_type ptype,
|
||||
const char *fmt,
|
||||
va_list args)
|
||||
{
|
||||
struct gl_context *ctx = data;
|
||||
enum mesa_debug_source source;
|
||||
enum mesa_debug_type type;
|
||||
enum mesa_debug_severity severity;
|
||||
|
||||
switch (ptype) {
|
||||
case PIPE_DEBUG_TYPE_OUT_OF_MEMORY:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_ERROR;
|
||||
severity = MESA_DEBUG_SEVERITY_MEDIUM;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_ERROR:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_ERROR;
|
||||
severity = MESA_DEBUG_SEVERITY_MEDIUM;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_SHADER_INFO:
|
||||
source = MESA_DEBUG_SOURCE_SHADER_COMPILER;
|
||||
type = MESA_DEBUG_TYPE_OTHER;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_PERF_INFO:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_PERFORMANCE;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_INFO:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_OTHER;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_FALLBACK:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_PERFORMANCE;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
case PIPE_DEBUG_TYPE_CONFORMANCE:
|
||||
source = MESA_DEBUG_SOURCE_API;
|
||||
type = MESA_DEBUG_TYPE_OTHER;
|
||||
severity = MESA_DEBUG_SEVERITY_NOTIFICATION;
|
||||
break;
|
||||
default:
|
||||
unreachable("invalid debug type");
|
||||
}
|
||||
_mesa_gl_vdebugf(ctx, id, source, type, severity, fmt, args);
|
||||
}
|
||||
|
||||
void
|
||||
st_update_debug_callback(struct gl_context *ctx)
|
||||
{
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
|
||||
if (!pipe->set_debug_callback)
|
||||
return;
|
||||
|
||||
if (_mesa_get_debug_state_int(ctx, GL_DEBUG_OUTPUT)) {
|
||||
struct pipe_debug_callback cb;
|
||||
memset(&cb, 0, sizeof(cb));
|
||||
cb.async = !_mesa_get_debug_state_int(ctx, GL_DEBUG_OUTPUT_SYNCHRONOUS);
|
||||
cb.debug_message = st_debug_message;
|
||||
cb.data = ctx;
|
||||
pipe->set_debug_callback(pipe, &cb);
|
||||
} else {
|
||||
pipe->set_debug_callback(pipe, NULL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,8 +46,6 @@ extern int ST_DEBUG;
|
|||
|
||||
void st_debug_init( void );
|
||||
|
||||
void st_update_debug_callback(struct gl_context *ctx);
|
||||
|
||||
static inline void
|
||||
ST_DBG( unsigned flag, const char *fmt, ... )
|
||||
{
|
||||
|
|
|
@ -958,7 +958,7 @@ st_api_create_context(struct st_api *stapi, struct st_manager *smapi,
|
|||
}
|
||||
|
||||
if (st->ctx->Const.ContextFlags & GL_CONTEXT_FLAG_DEBUG_BIT) {
|
||||
st_update_debug_callback(st->ctx);
|
||||
_mesa_update_debug_callback(st->ctx);
|
||||
}
|
||||
|
||||
if (attribs->flags & ST_CONTEXT_FLAG_FORWARD_COMPATIBLE)
|
||||
|
|
Loading…
Reference in New Issue