mesa/st: migrate debug callback code into mesa
authorDave Airlie <airlied@redhat.com>
Mon, 20 Dec 2021 04:09:14 +0000 (14:09 +1000)
committerMarge Bot <emma+marge@anholt.net>
Fri, 21 Jan 2022 01:18:19 +0000 (01:18 +0000)
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14632>

src/mesa/main/debug_output.c
src/mesa/main/debug_output.h
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_debug.c
src/mesa/state_tracker/st_debug.h
src/mesa/state_tracker/st_manager.c

index 693aeb4..04889a6 100644 (file)
@@ -37,6 +37,7 @@
 #include "util/u_memory.h"
 #include "api_exec_decl.h"
 
+#include "pipe/p_context.h"
 
 static GLuint PrevDynamicID = 0;
 
@@ -681,6 +682,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
  * debug state is not locked.
index 94e3bd0..63dc315 100644 (file)
@@ -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
index bf9682e..876099d 100644 (file)
@@ -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;
index 414f4ac..57820b7 100644 (file)
@@ -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);
-   }
-}
index 4d58816..35a194e 100644 (file)
@@ -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, ... )
 {
index 6d8ec02..7abe6b1 100644 (file)
@@ -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)