mirror of
https://github.com/brl/mutter.git
synced 2024-12-25 04:22:05 +00:00
[debug] Adds a COGL_DEBUG=matrices debug option
This adds a COGL_DEBUG=matrices debug option that can be used to trace all matrix manipulation done using the Cogl API. This can be handy when you break something in such a way that a trace is still comparable with a previous working version since you can simply diff a log of the broken version vs the working version to home in on the bug.
This commit is contained in:
parent
eb438dd499
commit
8051596e96
@ -46,7 +46,8 @@ static const GDebugKey cogl_debug_keys[] = {
|
|||||||
{ "disable-vbos", COGL_DEBUG_DISABLE_VBOS },
|
{ "disable-vbos", COGL_DEBUG_DISABLE_VBOS },
|
||||||
{ "journal", COGL_DEBUG_JOURNAL },
|
{ "journal", COGL_DEBUG_JOURNAL },
|
||||||
{ "batching", COGL_DEBUG_BATCHING },
|
{ "batching", COGL_DEBUG_BATCHING },
|
||||||
{ "disable-software-transform", COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM }
|
{ "disable-software-transform", COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM },
|
||||||
|
{ "matrices", COGL_DEBUG_MATRICES }
|
||||||
};
|
};
|
||||||
|
|
||||||
static const gint n_cogl_debug_keys = G_N_ELEMENTS (cogl_debug_keys);
|
static const gint n_cogl_debug_keys = G_N_ELEMENTS (cogl_debug_keys);
|
||||||
|
@ -44,7 +44,8 @@ typedef enum {
|
|||||||
COGL_DEBUG_DISABLE_VBOS = 1 << 12,
|
COGL_DEBUG_DISABLE_VBOS = 1 << 12,
|
||||||
COGL_DEBUG_JOURNAL = 1 << 13,
|
COGL_DEBUG_JOURNAL = 1 << 13,
|
||||||
COGL_DEBUG_BATCHING = 1 << 14,
|
COGL_DEBUG_BATCHING = 1 << 14,
|
||||||
COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM = 1 << 15
|
COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM = 1 << 15,
|
||||||
|
COGL_DEBUG_MATRICES = 1 << 16
|
||||||
} CoglDebugFlags;
|
} CoglDebugFlags;
|
||||||
|
|
||||||
#ifdef COGL_ENABLE_DEBUG
|
#ifdef COGL_ENABLE_DEBUG
|
||||||
|
47
clutter/cogl/cogl/cogl-matrix-private.h
Normal file
47
clutter/cogl/cogl/cogl-matrix-private.h
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Cogl
|
||||||
|
*
|
||||||
|
* An object oriented GL/GLES Abstraction/Utility Layer
|
||||||
|
*
|
||||||
|
* Copyright (C) 2008,2009 Intel Corporation.
|
||||||
|
*
|
||||||
|
* This library is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
* License as published by the Free Software Foundation; either
|
||||||
|
* version 2 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
* Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public
|
||||||
|
* License along with this library; if not, write to the
|
||||||
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
* Boston, MA 02111-1307, USA.
|
||||||
|
*
|
||||||
|
* Authors:
|
||||||
|
* Robert Bragg <robert@linux.intel.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __COGL_MATRIX_PRIVATE_H
|
||||||
|
#define __COGL_MATRIX_PRIVATE_H
|
||||||
|
|
||||||
|
#include <glib.h>
|
||||||
|
|
||||||
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
#define _COGL_MATRIX_DEBUG_PRINT(MATRIX) \
|
||||||
|
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_MATRICES)) \
|
||||||
|
{ \
|
||||||
|
g_print ("%s:\n", G_STRFUNC); \
|
||||||
|
_cogl_matrix_print (MATRIX); \
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
_cogl_matrix_print (CoglMatrix *matrix);
|
||||||
|
|
||||||
|
G_END_DECLS
|
||||||
|
|
||||||
|
#endif /* __COGL_MATRIX_PRIVATE_H */
|
||||||
|
|
@ -28,6 +28,7 @@
|
|||||||
|
|
||||||
#include <cogl.h>
|
#include <cogl.h>
|
||||||
#include <cogl-matrix.h>
|
#include <cogl-matrix.h>
|
||||||
|
#include <cogl-matrix-private.h>
|
||||||
#ifdef USE_MESA_MATRIX_API
|
#ifdef USE_MESA_MATRIX_API
|
||||||
#include <cogl-matrix-mesa.h>
|
#include <cogl-matrix-mesa.h>
|
||||||
#endif
|
#endif
|
||||||
@ -36,6 +37,16 @@
|
|||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
void
|
||||||
|
_cogl_matrix_print (CoglMatrix *matrix)
|
||||||
|
{
|
||||||
|
float *m = (float *)matrix;
|
||||||
|
int y;
|
||||||
|
|
||||||
|
for (y = 0; y < 4; y++)
|
||||||
|
g_print ("\t%6.4f %6.4f %6.4f %6.4f\n", m[y], m[4+y], m[8+y], m[12+y]);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cogl_matrix_init_identity (CoglMatrix *matrix)
|
cogl_matrix_init_identity (CoglMatrix *matrix)
|
||||||
{
|
{
|
||||||
@ -47,6 +58,7 @@ cogl_matrix_init_identity (CoglMatrix *matrix)
|
|||||||
#else
|
#else
|
||||||
_math_matrix_init_identity (matrix);
|
_math_matrix_init_identity (matrix);
|
||||||
#endif
|
#endif
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -90,6 +102,7 @@ cogl_matrix_multiply (CoglMatrix *result,
|
|||||||
#else
|
#else
|
||||||
_math_matrix_multiply (result, a, b);
|
_math_matrix_multiply (result, a, b);
|
||||||
#endif
|
#endif
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (result);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -133,6 +146,7 @@ cogl_matrix_rotate (CoglMatrix *matrix,
|
|||||||
#else
|
#else
|
||||||
_math_matrix_rotate (matrix, angle, x, y, z);
|
_math_matrix_rotate (matrix, angle, x, y, z);
|
||||||
#endif
|
#endif
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -149,6 +163,7 @@ cogl_matrix_translate (CoglMatrix *matrix,
|
|||||||
#else
|
#else
|
||||||
_math_matrix_translate (matrix, x, y, z);
|
_math_matrix_translate (matrix, x, y, z);
|
||||||
#endif
|
#endif
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -165,6 +180,7 @@ cogl_matrix_scale (CoglMatrix *matrix,
|
|||||||
#else
|
#else
|
||||||
_math_matrix_scale (matrix, sx, sy, sz);
|
_math_matrix_scale (matrix, sx, sy, sz);
|
||||||
#endif
|
#endif
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
@ -223,6 +239,7 @@ cogl_matrix_frustum (CoglMatrix *matrix,
|
|||||||
#else
|
#else
|
||||||
_math_matrix_frustum (matrix, left, right, bottom, top, z_near, z_far);
|
_math_matrix_frustum (matrix, left, right, bottom, top, z_near, z_far);
|
||||||
#endif
|
#endif
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -241,6 +258,7 @@ cogl_matrix_perspective (CoglMatrix *matrix,
|
|||||||
ymax, /* top */
|
ymax, /* top */
|
||||||
z_near,
|
z_near,
|
||||||
z_far);
|
z_far);
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -283,6 +301,7 @@ cogl_matrix_ortho (CoglMatrix *matrix,
|
|||||||
#else
|
#else
|
||||||
_math_matrix_ortho (matrix, left, right, bottom, top, near_val, far_val);
|
_math_matrix_ortho (matrix, left, right, bottom, top, near_val, far_val);
|
||||||
#endif
|
#endif
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -293,6 +312,7 @@ cogl_matrix_init_from_array (CoglMatrix *matrix, const float *array)
|
|||||||
#else
|
#else
|
||||||
_math_matrix_init_from_array (matrix, array);
|
_math_matrix_init_from_array (matrix, array);
|
||||||
#endif
|
#endif
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
const float *
|
const float *
|
||||||
|
@ -39,6 +39,7 @@
|
|||||||
#include "cogl-material-private.h"
|
#include "cogl-material-private.h"
|
||||||
#include "cogl-winsys.h"
|
#include "cogl-winsys.h"
|
||||||
#include "cogl-draw-buffer-private.h"
|
#include "cogl-draw-buffer-private.h"
|
||||||
|
#include "cogl-matrix-private.h"
|
||||||
|
|
||||||
#if defined (HAVE_COGL_GLES2) || defined (HAVE_COGL_GLES)
|
#if defined (HAVE_COGL_GLES2) || defined (HAVE_COGL_GLES)
|
||||||
#include "cogl-gles2-wrapper.h"
|
#include "cogl-gles2-wrapper.h"
|
||||||
@ -1165,6 +1166,7 @@ cogl_get_modelview_matrix (CoglMatrix *matrix)
|
|||||||
CoglMatrixStack *modelview_stack =
|
CoglMatrixStack *modelview_stack =
|
||||||
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ());
|
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ());
|
||||||
_cogl_matrix_stack_get (modelview_stack, matrix);
|
_cogl_matrix_stack_get (modelview_stack, matrix);
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1173,6 +1175,7 @@ cogl_set_modelview_matrix (CoglMatrix *matrix)
|
|||||||
CoglMatrixStack *modelview_stack =
|
CoglMatrixStack *modelview_stack =
|
||||||
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ());
|
_cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ());
|
||||||
_cogl_matrix_stack_set (modelview_stack, matrix);
|
_cogl_matrix_stack_set (modelview_stack, matrix);
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1181,6 +1184,7 @@ cogl_get_projection_matrix (CoglMatrix *matrix)
|
|||||||
CoglMatrixStack *projection_stack =
|
CoglMatrixStack *projection_stack =
|
||||||
_cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ());
|
_cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ());
|
||||||
_cogl_matrix_stack_get (projection_stack, matrix);
|
_cogl_matrix_stack_get (projection_stack, matrix);
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1192,6 +1196,7 @@ cogl_set_projection_matrix (CoglMatrix *matrix)
|
|||||||
|
|
||||||
/* FIXME: Update the inverse projection matrix!! Presumably use
|
/* FIXME: Update the inverse projection matrix!! Presumably use
|
||||||
* of clip planes must currently be broken if this API is used. */
|
* of clip planes must currently be broken if this API is used. */
|
||||||
|
_COGL_MATRIX_DEBUG_PRINT (matrix);
|
||||||
}
|
}
|
||||||
|
|
||||||
CoglClipStackState *
|
CoglClipStackState *
|
||||||
|
Loading…
Reference in New Issue
Block a user