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>
This commit is contained in:
Jonas Ådahl 2020-12-18 11:26:19 +01:00 committed by Marge Bot
parent 96842fc570
commit 46ec29458d
4 changed files with 36 additions and 7 deletions

View File

@ -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"))

View File

@ -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);

View File

@ -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;

View File

@ -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;
}