[mutter] cogl/texture: Add a bit more debug logging



commit 46ec29458d0833ec689e935d7ff86c2ecccb05a0
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Dec 18 11:26:19 2020 +0100

    cogl/texture: Add a bit more debug logging
    
    We fall back to slicing if the non-sliced allocation failed, but we
    didn't log why. Also log why allocating a slice failed.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1648>

 cogl/cogl/cogl-debug-options.h           |  5 +++++
 cogl/cogl/cogl-debug.c                   |  3 ++-
 cogl/cogl/cogl-debug.h                   |  1 +
 cogl/cogl/deprecated/cogl-auto-texture.c | 34 ++++++++++++++++++++++++++------
 4 files changed, 36 insertions(+), 7 deletions(-)
---
diff --git a/cogl/cogl/cogl-debug-options.h b/cogl/cogl/cogl-debug-options.h
index 8450becd1b..f6cda51a2d 100644
--- a/cogl/cogl/cogl-debug-options.h
+++ b/cogl/cogl/cogl-debug-options.h
@@ -184,3 +184,8 @@ OPT (SYNC_FRAME,
      N_("Call glFinish after rendering each frame, so profilers can measure "
         "the total render time (as a portion of the stage update time) more "
         "accurately."))
+OPT (TEXTURES,
+     N_("Cogl Tracing"),
+     "textures",
+     N_("Debug texture management"),
+     N_("Logs information about texture management"))
diff --git a/cogl/cogl/cogl-debug.c b/cogl/cogl/cogl-debug.c
index 800f448df7..2d2420ffd9 100644
--- a/cogl/cogl/cogl-debug.c
+++ b/cogl/cogl/cogl-debug.c
@@ -62,7 +62,8 @@ static const GDebugKey cogl_log_debug_keys[] = {
   { "bitmap", COGL_DEBUG_BITMAP },
   { "clipping", COGL_DEBUG_CLIPPING },
   { "winsys", COGL_DEBUG_WINSYS },
-  { "performance", COGL_DEBUG_PERFORMANCE }
+  { "performance", COGL_DEBUG_PERFORMANCE },
+  { "textures", COGL_DEBUG_TEXTURES },
 };
 static const int n_cogl_log_debug_keys =
   G_N_ELEMENTS (cogl_log_debug_keys);
diff --git a/cogl/cogl/cogl-debug.h b/cogl/cogl/cogl-debug.h
index d6bc358b5e..09a356eddc 100644
--- a/cogl/cogl/cogl-debug.h
+++ b/cogl/cogl/cogl-debug.h
@@ -73,6 +73,7 @@ typedef enum
   COGL_DEBUG_PERFORMANCE,
   COGL_DEBUG_SYNC_PRIMITIVE,
   COGL_DEBUG_SYNC_FRAME,
+  COGL_DEBUG_TEXTURES,
 
   COGL_DEBUG_N_FLAGS
 } CoglDebugFlags;
diff --git a/cogl/cogl/deprecated/cogl-auto-texture.c b/cogl/cogl/deprecated/cogl-auto-texture.c
index ca009ee9af..99431a5c2c 100644
--- a/cogl/cogl/deprecated/cogl-auto-texture.c
+++ b/cogl/cogl/deprecated/cogl-auto-texture.c
@@ -177,7 +177,7 @@ cogl_texture_new_from_data (int width,
                             int rowstride,
                             const uint8_t *data)
 {
-  GError *ignore_error = NULL;
+  g_autoptr (GError) error = NULL;
   CoglTexture *tex;
 
   _COGL_GET_CONTEXT (ctx, NULL);
@@ -188,9 +188,17 @@ cogl_texture_new_from_data (int width,
                                      format, internal_format,
                                      rowstride,
                                      data,
-                                     &ignore_error);
+                                     &error);
   if (!tex)
-    g_error_free (ignore_error);
+    {
+      COGL_NOTE (TEXTURES, "Failed to create texture with size %dx%d and "
+                 "format %s (internal: %s) from data: %s",
+                 width, height,
+                 cogl_pixel_format_to_string (format),
+                 cogl_pixel_format_to_string (internal_format),
+                 error->message);
+      return NULL;
+    }
   return tex;
 }
 
@@ -231,6 +239,15 @@ _cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
 
   if (!cogl_texture_allocate (tex, &internal_error))
     {
+      COGL_NOTE (TEXTURES,
+                 "Failed to allocate texture from bitmap with size "
+                 "%dx%d and format %s (internal: %s), "
+                 "falling back on slicing: %s",
+                 cogl_bitmap_get_width (bitmap),
+                 cogl_bitmap_get_height (bitmap),
+                 cogl_pixel_format_to_string (cogl_bitmap_get_format (bitmap)),
+                 cogl_pixel_format_to_string (internal_format),
+                 internal_error->message);
       g_error_free (internal_error);
       internal_error = NULL;
       cogl_object_unref (tex);
@@ -273,15 +290,20 @@ cogl_texture_new_from_bitmap (CoglBitmap *bitmap,
                               CoglTextureFlags flags,
                               CoglPixelFormat internal_format)
 {
-  GError *ignore_error = NULL;
+  g_autoptr (GError) error = NULL;
+
   CoglTexture *tex =
     _cogl_texture_new_from_bitmap (bitmap,
                                    flags,
                                    internal_format,
                                    FALSE, /* can't convert in-place */
-                                   &ignore_error);
+                                   &error);
   if (!tex)
-    g_error_free (ignore_error);
+    {
+      COGL_NOTE (TEXTURES, "Failed to create texture from bitmap: %s",
+                 error->message);
+      return NULL;
+    }
   return tex;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]