cogl-debug: Split the flags to support more than 32
The CoglDebugFlags are now stored in an array of unsigned ints rather than a single variable. The flags are accessed using macros instead of directly peeking at the cogl_debug_flags variable. The index values are stored in the enum rather than the actual mask values so that the enum doesn't need to be more than 32 bits wide. The hope is that the code to determine the index into the array can be optimized out by the compiler so it should have exactly the same performance as the old code.
This commit is contained in:
parent
4bb08ba00b
commit
c4a94439de
@ -535,7 +535,7 @@ _cogl_atlas_texture_new_from_bitmap (CoglBitmap *bmp,
|
||||
|
||||
/* Don't put textures in the atlas if the user has explicitly
|
||||
requested to disable it */
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_ATLAS))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_ATLAS)))
|
||||
return COGL_INVALID_HANDLE;
|
||||
|
||||
/* We can't put the texture in the atlas if there are any special
|
||||
|
@ -1036,7 +1036,7 @@ draw_wireframe (CoglVerticesMode mode,
|
||||
cogl_push_source (wire_pipeline);
|
||||
|
||||
/* temporarily disable the wireframe to avoid recursion! */
|
||||
cogl_debug_flags &= ~COGL_DEBUG_WIREFRAME;
|
||||
COGL_DEBUG_CLEAR_FLAG (COGL_DEBUG_WIREFRAME);
|
||||
_cogl_draw_attributes_array (COGL_VERTICES_MODE_LINES,
|
||||
0,
|
||||
n_line_vertices,
|
||||
@ -1046,7 +1046,7 @@ draw_wireframe (CoglVerticesMode mode,
|
||||
COGL_DRAW_SKIP_FRAMEBUFFER_FLUSH |
|
||||
COGL_DRAW_SKIP_LEGACY_STATE);
|
||||
|
||||
cogl_debug_flags |= COGL_DEBUG_WIREFRAME;
|
||||
COGL_DEBUG_SET_FLAG (COGL_DEBUG_WIREFRAME);
|
||||
|
||||
cogl_pop_source ();
|
||||
|
||||
@ -1107,7 +1107,7 @@ _cogl_draw_attributes_array (CoglVerticesMode mode,
|
||||
disable_gl_state (attributes, source);
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_WIREFRAME))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_WIREFRAME)))
|
||||
draw_wireframe (mode, first_vertex, n_vertices, attributes, NULL);
|
||||
#endif
|
||||
}
|
||||
@ -1219,7 +1219,7 @@ _cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
|
||||
disable_gl_state (attributes, source);
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_WIREFRAME))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_WIREFRAME)))
|
||||
draw_wireframe (mode, first_vertex, n_vertices, attributes, indices);
|
||||
#endif
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ error:
|
||||
"Invalid texture combine string: %s",
|
||||
error_string);
|
||||
|
||||
if (cogl_debug_flags & COGL_DEBUG_BLEND_STRINGS)
|
||||
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
|
||||
{
|
||||
g_debug ("Invalid texture combine string: %s",
|
||||
error_string);
|
||||
@ -321,7 +321,7 @@ error:
|
||||
"blend" : "texture combine",
|
||||
error_string);
|
||||
|
||||
if (cogl_debug_flags & COGL_DEBUG_BLEND_STRINGS)
|
||||
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
|
||||
{
|
||||
g_debug ("Invalid %s string: %s",
|
||||
context == COGL_BLEND_STRING_CONTEXT_BLENDING ?
|
||||
@ -728,7 +728,7 @@ error:
|
||||
offset,
|
||||
error_string);
|
||||
|
||||
if (cogl_debug_flags & COGL_DEBUG_BLEND_STRINGS)
|
||||
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
|
||||
{
|
||||
g_debug ("Syntax error for argument %d at offset %d: %s",
|
||||
current_arg, offset, error_string);
|
||||
@ -753,10 +753,10 @@ _cogl_blend_string_compile (const char *string,
|
||||
int remaining_argc = 0;
|
||||
|
||||
#if 0
|
||||
cogl_debug_flags |= COGL_DEBUG_BLEND_STRINGS;
|
||||
COGL_DEBUG_SET_FLAG (COGL_DEBUG_BLEND_STRINGS);
|
||||
#endif
|
||||
|
||||
if (cogl_debug_flags & COGL_DEBUG_BLEND_STRINGS)
|
||||
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
|
||||
{
|
||||
COGL_NOTE (BLEND_STRINGS, "Compiling %s string:\n%s\n",
|
||||
context == COGL_BLEND_STRING_CONTEXT_BLENDING ?
|
||||
@ -882,7 +882,7 @@ _cogl_blend_string_compile (const char *string,
|
||||
|
||||
finished:
|
||||
|
||||
if (cogl_debug_flags & COGL_DEBUG_BLEND_STRINGS)
|
||||
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
|
||||
{
|
||||
if (current_statement > 0)
|
||||
print_statement (0, &statements[0]);
|
||||
@ -908,7 +908,7 @@ error:
|
||||
offset,
|
||||
error_string);
|
||||
|
||||
if (cogl_debug_flags & COGL_DEBUG_BLEND_STRINGS)
|
||||
if (COGL_DEBUG_ENABLED (COGL_DEBUG_BLEND_STRINGS))
|
||||
{
|
||||
g_debug ("Syntax error at offset %d: %s",
|
||||
offset, error_string);
|
||||
|
@ -62,19 +62,19 @@ static gboolean gl_is_indirect = FALSE;
|
||||
static void
|
||||
_cogl_init_feature_overrides (CoglContext *ctx)
|
||||
{
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_VBOS))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_VBOS)))
|
||||
ctx->feature_flags &= ~COGL_FEATURE_VBOS;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_PBOS))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_PBOS)))
|
||||
ctx->feature_flags &= ~COGL_FEATURE_PBOS;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_ARBFP))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_ARBFP)))
|
||||
ctx->feature_flags &= ~COGL_FEATURE_SHADERS_ARBFP;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_GLSL))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_GLSL)))
|
||||
ctx->feature_flags &= ~COGL_FEATURE_SHADERS_GLSL;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_NPOT_TEXTURES))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_NPOT_TEXTURES)))
|
||||
ctx->feature_flags &= ~(COGL_FEATURE_TEXTURE_NPOT |
|
||||
COGL_FEATURE_TEXTURE_NPOT_BASIC |
|
||||
COGL_FEATURE_TEXTURE_NPOT_MIPMAP |
|
||||
|
@ -83,17 +83,57 @@ static const int n_cogl_behavioural_debug_keys =
|
||||
|
||||
#endif /* COGL_ENABLE_DEBUG */
|
||||
|
||||
unsigned int cogl_debug_flags = 0;
|
||||
unsigned int _cogl_debug_flags[COGL_DEBUG_N_INTS];
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
static unsigned int
|
||||
|
||||
static void
|
||||
_cogl_parse_debug_string_for_keys (const char *value,
|
||||
gboolean enable,
|
||||
const GDebugKey *keys,
|
||||
unsigned int nkeys)
|
||||
{
|
||||
int int_num, key_num;
|
||||
|
||||
/* g_parse_debug_string expects the value field in GDebugKey to be a
|
||||
mask in a guint but we may have multiple guints so we need to
|
||||
build a separate array for each possible guint */
|
||||
|
||||
for (int_num = 0; int_num < COGL_DEBUG_N_INTS; int_num++)
|
||||
{
|
||||
GDebugKey keys_for_int[sizeof (unsigned int) * 8];
|
||||
unsigned int mask_for_int;
|
||||
int nkeys_for_int = 0;
|
||||
|
||||
for (key_num = 0; key_num < nkeys; key_num++)
|
||||
if (COGL_DEBUG_GET_FLAG_INDEX (keys[key_num].value) == int_num)
|
||||
{
|
||||
keys_for_int[nkeys_for_int] = keys[key_num];
|
||||
keys_for_int[nkeys_for_int].value =
|
||||
COGL_DEBUG_GET_FLAG_MASK (keys[key_num].value);
|
||||
nkeys_for_int++;
|
||||
}
|
||||
|
||||
if (nkeys_for_int > 0)
|
||||
{
|
||||
mask_for_int = g_parse_debug_string (value,
|
||||
keys_for_int,
|
||||
nkeys_for_int);
|
||||
if (enable)
|
||||
_cogl_debug_flags[int_num] |= mask_for_int;
|
||||
else
|
||||
_cogl_debug_flags[int_num] &= ~mask_for_int;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cogl_parse_debug_string (const char *value,
|
||||
gboolean enable,
|
||||
gboolean ignore_help)
|
||||
{
|
||||
unsigned int flags = 0;
|
||||
|
||||
if (ignore_help && strcmp (value, "help") == 0)
|
||||
return 0;
|
||||
return;
|
||||
|
||||
/* We don't want to let g_parse_debug_string handle "all" because
|
||||
* literally enabling all the debug options wouldn't be useful to
|
||||
@ -105,7 +145,10 @@ _cogl_parse_debug_string (const char *value,
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < n_cogl_log_debug_keys; i++)
|
||||
flags |= cogl_log_debug_keys[i].value;
|
||||
if (enable)
|
||||
COGL_DEBUG_SET_FLAG (cogl_log_debug_keys[i].value);
|
||||
else
|
||||
COGL_DEBUG_CLEAR_FLAG (cogl_log_debug_keys[i].value);
|
||||
}
|
||||
else if (strcmp (value, "help") == 0)
|
||||
{
|
||||
@ -123,17 +166,15 @@ _cogl_parse_debug_string (const char *value,
|
||||
}
|
||||
else
|
||||
{
|
||||
flags |=
|
||||
g_parse_debug_string (value,
|
||||
_cogl_parse_debug_string_for_keys (value,
|
||||
enable,
|
||||
cogl_log_debug_keys,
|
||||
n_cogl_log_debug_keys);
|
||||
flags |=
|
||||
g_parse_debug_string (value,
|
||||
_cogl_parse_debug_string_for_keys (value,
|
||||
enable,
|
||||
cogl_behavioural_debug_keys,
|
||||
n_cogl_behavioural_debug_keys);
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -141,7 +182,9 @@ cogl_arg_debug_cb (const char *key,
|
||||
const char *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
cogl_debug_flags |= _cogl_parse_debug_string (value, FALSE);
|
||||
_cogl_parse_debug_string (value,
|
||||
TRUE /* enable the flags */,
|
||||
FALSE /* don't ignore help */);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@ -150,7 +193,9 @@ cogl_arg_no_debug_cb (const char *key,
|
||||
const char *value,
|
||||
gpointer user_data)
|
||||
{
|
||||
cogl_debug_flags &= ~_cogl_parse_debug_string (value, TRUE);
|
||||
_cogl_parse_debug_string (value,
|
||||
FALSE, /* disable the flags */
|
||||
TRUE /* ignore help */);
|
||||
return TRUE;
|
||||
}
|
||||
#endif /* COGL_ENABLE_DEBUG */
|
||||
@ -177,7 +222,9 @@ pre_parse_hook (GOptionContext *context,
|
||||
env_string = g_getenv ("COGL_DEBUG");
|
||||
if (env_string != NULL)
|
||||
{
|
||||
cogl_debug_flags |= _cogl_parse_debug_string (env_string, FALSE);
|
||||
_cogl_parse_debug_string (env_string,
|
||||
TRUE /* enable the flags */,
|
||||
FALSE /* don't ignore help */);
|
||||
env_string = NULL;
|
||||
}
|
||||
#endif /* COGL_ENABLE_DEBUG */
|
||||
|
@ -31,50 +31,79 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef enum {
|
||||
COGL_DEBUG_SLICING = 1 << 0,
|
||||
COGL_DEBUG_OFFSCREEN = 1 << 1,
|
||||
COGL_DEBUG_DRAW = 1 << 2,
|
||||
COGL_DEBUG_PANGO = 1 << 3,
|
||||
COGL_DEBUG_RECTANGLES = 1 << 4,
|
||||
COGL_DEBUG_HANDLE = 1 << 5,
|
||||
COGL_DEBUG_BLEND_STRINGS = 1 << 6,
|
||||
COGL_DEBUG_DISABLE_BATCHING = 1 << 7,
|
||||
COGL_DEBUG_DISABLE_VBOS = 1 << 8,
|
||||
COGL_DEBUG_DISABLE_PBOS = 1 << 9,
|
||||
COGL_DEBUG_JOURNAL = 1 << 10,
|
||||
COGL_DEBUG_BATCHING = 1 << 11,
|
||||
COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM = 1 << 12,
|
||||
COGL_DEBUG_MATRICES = 1 << 13,
|
||||
COGL_DEBUG_ATLAS = 1 << 14,
|
||||
COGL_DEBUG_DUMP_ATLAS_IMAGE = 1 << 15,
|
||||
COGL_DEBUG_DISABLE_ATLAS = 1 << 16,
|
||||
COGL_DEBUG_OPENGL = 1 << 17,
|
||||
COGL_DEBUG_DISABLE_TEXTURING = 1 << 18,
|
||||
COGL_DEBUG_DISABLE_ARBFP = 1 << 19,
|
||||
COGL_DEBUG_DISABLE_FIXED = 1 << 20,
|
||||
COGL_DEBUG_DISABLE_GLSL = 1 << 21,
|
||||
COGL_DEBUG_SHOW_SOURCE = 1 << 22,
|
||||
COGL_DEBUG_DISABLE_BLENDING = 1 << 23,
|
||||
COGL_DEBUG_TEXTURE_PIXMAP = 1 << 24,
|
||||
COGL_DEBUG_BITMAP = 1 << 25,
|
||||
COGL_DEBUG_DISABLE_NPOT_TEXTURES = 1 << 26,
|
||||
COGL_DEBUG_WIREFRAME = 1 << 27,
|
||||
COGL_DEBUG_DISABLE_SOFTWARE_CLIP = 1 << 28,
|
||||
COGL_DEBUG_DISABLE_PROGRAM_CACHES = 1 << 29,
|
||||
COGL_DEBUG_DISABLE_FAST_READ_PIXEL = 1 << 30
|
||||
COGL_DEBUG_SLICING,
|
||||
COGL_DEBUG_OFFSCREEN,
|
||||
COGL_DEBUG_DRAW,
|
||||
COGL_DEBUG_PANGO,
|
||||
COGL_DEBUG_RECTANGLES,
|
||||
COGL_DEBUG_HANDLE,
|
||||
COGL_DEBUG_BLEND_STRINGS,
|
||||
COGL_DEBUG_DISABLE_BATCHING,
|
||||
COGL_DEBUG_DISABLE_VBOS,
|
||||
COGL_DEBUG_DISABLE_PBOS,
|
||||
COGL_DEBUG_JOURNAL,
|
||||
COGL_DEBUG_BATCHING,
|
||||
COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM,
|
||||
COGL_DEBUG_MATRICES,
|
||||
COGL_DEBUG_ATLAS,
|
||||
COGL_DEBUG_DUMP_ATLAS_IMAGE,
|
||||
COGL_DEBUG_DISABLE_ATLAS,
|
||||
COGL_DEBUG_OPENGL,
|
||||
COGL_DEBUG_DISABLE_TEXTURING,
|
||||
COGL_DEBUG_DISABLE_ARBFP,
|
||||
COGL_DEBUG_DISABLE_FIXED,
|
||||
COGL_DEBUG_DISABLE_GLSL,
|
||||
COGL_DEBUG_SHOW_SOURCE,
|
||||
COGL_DEBUG_DISABLE_BLENDING,
|
||||
COGL_DEBUG_TEXTURE_PIXMAP,
|
||||
COGL_DEBUG_BITMAP,
|
||||
COGL_DEBUG_DISABLE_NPOT_TEXTURES,
|
||||
COGL_DEBUG_WIREFRAME,
|
||||
COGL_DEBUG_DISABLE_SOFTWARE_CLIP,
|
||||
COGL_DEBUG_DISABLE_PROGRAM_CACHES,
|
||||
COGL_DEBUG_DISABLE_FAST_READ_PIXEL,
|
||||
|
||||
COGL_DEBUG_N_FLAGS
|
||||
} CoglDebugFlags;
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
|
||||
#define COGL_DEBUG_N_INTS ((COGL_DEBUG_N_FLAGS + \
|
||||
(sizeof (unsigned int) * 8 - 1)) \
|
||||
/ (sizeof (unsigned int) * 8))
|
||||
|
||||
/* It would probably make sense to use unsigned long here instead
|
||||
because then on 64-bit systems where it can handle 64-bits just as
|
||||
easily and it can test more bits. However GDebugKey uses a guint
|
||||
for the mask and we need to fit the masks into this */
|
||||
extern unsigned int _cogl_debug_flags[COGL_DEBUG_N_INTS];
|
||||
|
||||
#define COGL_DEBUG_GET_FLAG_INDEX(flag) \
|
||||
((flag) / (sizeof (unsigned int) * 8))
|
||||
#define COGL_DEBUG_GET_FLAG_MASK(flag) \
|
||||
(1U << ((unsigned int) (flag) & (sizeof (unsigned int) * 8 - 1)))
|
||||
|
||||
#define COGL_DEBUG_ENABLED(flag) \
|
||||
(!!(_cogl_debug_flags[COGL_DEBUG_GET_FLAG_INDEX (flag)] & \
|
||||
COGL_DEBUG_GET_FLAG_MASK (flag)))
|
||||
|
||||
#define COGL_DEBUG_SET_FLAG(flag) \
|
||||
(_cogl_debug_flags[COGL_DEBUG_GET_FLAG_INDEX (flag)] |= \
|
||||
COGL_DEBUG_GET_FLAG_MASK (flag))
|
||||
|
||||
#define COGL_DEBUG_CLEAR_FLAG(flag) \
|
||||
(_cogl_debug_flags[COGL_DEBUG_GET_FLAG_INDEX (flag)] &= \
|
||||
~COGL_DEBUG_GET_FLAG_MASK (flag))
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define COGL_NOTE(type,x,a...) G_STMT_START { \
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_##type)) { \
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type))) { \
|
||||
_cogl_profile_trace_message ("[" #type "] " G_STRLOC " & " x, ##a); \
|
||||
} } G_STMT_END
|
||||
|
||||
#else
|
||||
#define COGL_NOTE(type,...) G_STMT_START { \
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_##type)) { \
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_##type)) { \
|
||||
char *_fmt = g_strdup_printf (__VA_ARGS__); \
|
||||
_cogl_profile_trace_message ("[" #type "] " G_STRLOC " & %s", _fmt);\
|
||||
g_free (_fmt); \
|
||||
@ -86,9 +115,15 @@ typedef enum {
|
||||
|
||||
#define COGL_NOTE(type,...) G_STMT_START {} G_STMT_END
|
||||
|
||||
#endif /* COGL_ENABLE_DEBUG */
|
||||
#define COGL_DEBUG_ENABLED(flag) FALSE
|
||||
|
||||
extern unsigned int cogl_debug_flags;
|
||||
#define COGL_DEBUG_SET_FLAG(flag) \
|
||||
G_STMT_START { } G_STMT_END
|
||||
|
||||
#define COGL_DEBUG_CLEAR_FLAG(flag) \
|
||||
G_STMT_START { } G_STMT_END
|
||||
|
||||
#endif /* COGL_ENABLE_DEBUG */
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -372,7 +372,7 @@ _cogl_framebuffer_clear4f (CoglFramebuffer *framebuffer,
|
||||
* batches from the journal. It is reset here to increase the
|
||||
* chances of getting the same colours for each frame during an
|
||||
* animation */
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_RECTANGLES) &&
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_RECTANGLES)) &&
|
||||
buffers & COGL_BUFFER_BIT_COLOR)
|
||||
{
|
||||
_COGL_GET_CONTEXT (ctxt, NO_RETVAL);
|
||||
@ -1237,7 +1237,7 @@ _cogl_framebuffer_try_fast_read_pixel (CoglFramebuffer *framebuffer,
|
||||
{
|
||||
gboolean found_intersection;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_FAST_READ_PIXEL))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FAST_READ_PIXEL)))
|
||||
return FALSE;
|
||||
|
||||
if (source != COGL_READ_PIXELS_COLOR_BUFFER)
|
||||
|
@ -75,8 +75,8 @@
|
||||
*
|
||||
* So for a given number of layers this gets the stride in 32bit words:
|
||||
*/
|
||||
#define SW_TRANSFORM (!(cogl_debug_flags & \
|
||||
COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM))
|
||||
#define SW_TRANSFORM (!(COGL_DEBUG_ENABLED \
|
||||
(COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM)))
|
||||
#define POS_STRIDE (SW_TRANSFORM ? 3 : 2) /* number of 32bit words */
|
||||
#define N_POS_COMPONENTS POS_STRIDE
|
||||
#define COLOR_STRIDE 1 /* number of 32bit words */
|
||||
@ -191,8 +191,8 @@ _cogl_journal_dump_quad_vertices (guint8 *data, int n_layers)
|
||||
guint8 *c = data + (POS_STRIDE * 4) + (i * stride * 4);
|
||||
int j;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags &
|
||||
COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED
|
||||
(COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM)))
|
||||
g_print ("v%d: x = %f, y = %f, rgba=0x%02X%02X%02X%02X",
|
||||
i, v[0], v[1], c[0], c[1], c[2], c[3]);
|
||||
else
|
||||
@ -276,10 +276,10 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
||||
|
||||
COGL_TIMER_START (_cogl_uprof_context, time_flush_modelview_and_entries);
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_BATCHING)))
|
||||
g_print ("BATCHING: modelview batch len = %d\n", batch_len);
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM)))
|
||||
{
|
||||
_cogl_matrix_stack_set (state->modelview_stack,
|
||||
&batch_start->model_view);
|
||||
@ -327,7 +327,7 @@ _cogl_journal_flush_modelview_and_entries (CoglJournalEntry *batch_start,
|
||||
* issues, visually seeing what is batched and debugging blending
|
||||
* issues, plus it looks quite cool.
|
||||
*/
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_RECTANGLES))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_RECTANGLES)))
|
||||
{
|
||||
static CoglPipeline *outline = NULL;
|
||||
guint8 color_intensity;
|
||||
@ -421,14 +421,14 @@ _cogl_journal_flush_pipeline_and_entries (CoglJournalEntry *batch_start,
|
||||
|
||||
COGL_TIMER_START (_cogl_uprof_context, time_flush_pipeline_entries);
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_BATCHING)))
|
||||
g_print ("BATCHING: pipeline batch len = %d\n", batch_len);
|
||||
|
||||
state->source = batch_start->pipeline;
|
||||
|
||||
/* If we haven't transformed the quads in software then we need to also break
|
||||
* up batches according to changes in the modelview matrix... */
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM)))
|
||||
{
|
||||
batch_and_call (batch_start,
|
||||
batch_len,
|
||||
@ -571,7 +571,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
|
||||
COGL_TIMER_START (_cogl_uprof_context,
|
||||
time_flush_vbo_texcoord_pipeline_entries);
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_BATCHING)))
|
||||
g_print ("BATCHING: vbo offset batch len = %d\n", batch_len);
|
||||
|
||||
/* XXX NB:
|
||||
@ -621,7 +621,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
|
||||
*/
|
||||
state->current_vertex = 0;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_JOURNAL))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_JOURNAL)))
|
||||
{
|
||||
guint8 *verts;
|
||||
|
||||
@ -647,7 +647,7 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
|
||||
|
||||
/* progress forward through the VBO containing all our vertices */
|
||||
state->array_offset += (stride * 4 * batch_len);
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_JOURNAL))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_JOURNAL)))
|
||||
g_print ("new vbo offset = %lu\n", (unsigned long)state->array_offset);
|
||||
|
||||
COGL_TIMER_STOP (_cogl_uprof_context,
|
||||
@ -690,7 +690,7 @@ _cogl_journal_flush_clip_stacks_and_entries (CoglJournalEntry *batch_start,
|
||||
COGL_TIMER_START (_cogl_uprof_context,
|
||||
time_flush_clip_stack_pipeline_entries);
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_BATCHING)))
|
||||
g_print ("BATCHING: clip stack batch len = %d\n", batch_len);
|
||||
|
||||
_cogl_clip_stack_flush (batch_start->clip_stack);
|
||||
@ -701,7 +701,7 @@ _cogl_journal_flush_clip_stacks_and_entries (CoglJournalEntry *batch_start,
|
||||
* no further model transform is applied by loading the identity
|
||||
* matrix here. We need to do this after flushing the clip stack
|
||||
* because the clip stack flushing code can modify the matrix */
|
||||
if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM)))
|
||||
if (G_LIKELY (!(COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM))))
|
||||
{
|
||||
_cogl_matrix_stack_load_identity (state->modelview_stack);
|
||||
_cogl_matrix_stack_flush_to_gl (state->modelview_stack,
|
||||
@ -1125,7 +1125,7 @@ upload_vertices (const CoglJournalEntry *entries,
|
||||
memcpy (vout + vb_stride * i + POS_STRIDE, vin, 4);
|
||||
vin++;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM)))
|
||||
{
|
||||
vout[vb_stride * 0] = vin[0];
|
||||
vout[vb_stride * 0 + 1] = vin[1];
|
||||
@ -1304,7 +1304,7 @@ _cogl_journal_flush (CoglJournal *journal,
|
||||
|
||||
cogl_push_framebuffer (framebuffer);
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_BATCHING))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_BATCHING)))
|
||||
g_print ("BATCHING: journal len = %d\n", journal->entries->len);
|
||||
|
||||
/* NB: the journal deals with flushing the modelview stack and clip
|
||||
@ -1321,7 +1321,7 @@ _cogl_journal_flush (CoglJournal *journal,
|
||||
state.modelview_stack = modelview_stack;
|
||||
state.projection_stack = _cogl_framebuffer_get_projection_stack (framebuffer);
|
||||
|
||||
if (G_UNLIKELY ((cogl_debug_flags & COGL_DEBUG_DISABLE_SOFTWARE_CLIP) == 0))
|
||||
if (G_UNLIKELY ((COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_SOFTWARE_CLIP)) == 0))
|
||||
{
|
||||
/* We do an initial walk of the journal to analyse the clip stack
|
||||
batches to see if we can do software clipping. We do this as a
|
||||
@ -1470,7 +1470,7 @@ _cogl_journal_log_quad (CoglJournal *journal,
|
||||
memcpy (t + stride, tex_coords + i * 4 + 2, sizeof (float) * 2);
|
||||
}
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_JOURNAL))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_JOURNAL)))
|
||||
{
|
||||
g_print ("Logged new quad:\n");
|
||||
v = &g_array_index (journal->vertices, float, next_vert);
|
||||
@ -1533,7 +1533,7 @@ _cogl_journal_log_quad (CoglJournal *journal,
|
||||
* think a journal->framebuffer reference would seem nicer here but
|
||||
* the reason we don't have that currently is that it would
|
||||
* introduce a circular reference. */
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_BATCHING))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_BATCHING)))
|
||||
_cogl_framebuffer_flush_journal (_cogl_get_framebuffer ());
|
||||
|
||||
COGL_TIMER_STOP (_cogl_uprof_context, log_timer);
|
||||
|
@ -32,7 +32,7 @@
|
||||
G_BEGIN_DECLS
|
||||
|
||||
#define _COGL_MATRIX_DEBUG_PRINT(MATRIX) \
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_MATRICES)) \
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_MATRICES))) \
|
||||
{ \
|
||||
g_print ("%s:\n", G_STRFUNC); \
|
||||
_cogl_matrix_print (MATRIX); \
|
||||
|
@ -262,7 +262,7 @@ _cogl_pipeline_fragend_arbfp_start (CoglPipeline *pipeline,
|
||||
/* If we haven't yet found an existing program then before we resort to
|
||||
* generating a new arbfp program we see if we can find a suitable
|
||||
* program in the arbfp_cache. */
|
||||
if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_DISABLE_PROGRAM_CACHES)))
|
||||
if (G_LIKELY (!(COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_PROGRAM_CACHES))))
|
||||
{
|
||||
arbfp_program_state = g_hash_table_lookup (ctx->arbfp_cache, authority);
|
||||
if (arbfp_program_state)
|
||||
@ -891,7 +891,7 @@ _cogl_pipeline_fragend_arbfp_end (CoglPipeline *pipeline,
|
||||
"MOV result.color,output;\n");
|
||||
g_string_append (arbfp_program_state->source, "END\n");
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_SHOW_SOURCE))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE)))
|
||||
g_message ("pipeline program:\n%s", arbfp_program_state->source->str);
|
||||
|
||||
GE (glGenPrograms (1, &arbfp_program_state->gl_program));
|
||||
@ -914,7 +914,7 @@ _cogl_pipeline_fragend_arbfp_end (CoglPipeline *pipeline,
|
||||
|
||||
arbfp_program_state->source = NULL;
|
||||
|
||||
if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_DISABLE_PROGRAM_CACHES)))
|
||||
if (G_LIKELY (!(COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_PROGRAM_CACHES))))
|
||||
{
|
||||
CoglPipeline *key;
|
||||
|
||||
|
@ -92,7 +92,7 @@ _cogl_pipeline_fragend_fixed_start (CoglPipeline *pipeline,
|
||||
{
|
||||
CoglHandle user_program;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_FIXED))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED)))
|
||||
return FALSE;
|
||||
|
||||
/* If there is a user program with a fragment shader then the
|
||||
@ -165,7 +165,7 @@ _cogl_pipeline_fragend_fixed_add_layer (CoglPipeline *pipeline,
|
||||
GE (glDisable (unit->enabled_gl_target));
|
||||
|
||||
/* Enable the new target */
|
||||
if (!G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_TEXTURING))
|
||||
if (!G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)))
|
||||
{
|
||||
GE (glEnable (gl_target));
|
||||
unit->enabled_gl_target = gl_target;
|
||||
@ -179,7 +179,7 @@ _cogl_pipeline_fragend_fixed_add_layer (CoglPipeline *pipeline,
|
||||
* texture unit has been disabled for some time so we need to assert that
|
||||
* it's enabled now.
|
||||
*/
|
||||
if (!G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_TEXTURING) &&
|
||||
if (!G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_TEXTURING)) &&
|
||||
!unit->enabled_gl_target == 0)
|
||||
{
|
||||
_cogl_set_active_texture_unit (unit_index);
|
||||
|
@ -49,7 +49,7 @@ _cogl_pipeline_vertend_fixed_start (CoglPipeline *pipeline,
|
||||
{
|
||||
CoglProgram *user_program;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_FIXED))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_FIXED)))
|
||||
return FALSE;
|
||||
|
||||
/* If there is a user program with a vertex shader then the
|
||||
|
@ -837,7 +837,7 @@ _cogl_pipeline_needs_blending_enabled (CoglPipeline *pipeline,
|
||||
CoglPipelineBlendEnable enabled;
|
||||
unsigned long other_state;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_BLENDING))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DISABLE_BLENDING)))
|
||||
return FALSE;
|
||||
|
||||
enable_authority =
|
||||
|
@ -12,7 +12,7 @@ static gboolean
|
||||
debug_option_getter (void *user_data)
|
||||
{
|
||||
unsigned int shift = GPOINTER_TO_UINT (user_data);
|
||||
return (cogl_debug_flags & (1 << shift)) ? TRUE : FALSE;
|
||||
return COGL_DEBUG_ENABLED (shift);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -21,9 +21,9 @@ debug_option_setter (gboolean value, void *user_data)
|
||||
unsigned int shift = GPOINTER_TO_UINT (user_data);
|
||||
|
||||
if (value)
|
||||
cogl_debug_flags |= (1 << shift);
|
||||
COGL_DEBUG_SET_FLAG (shift);
|
||||
else
|
||||
cogl_debug_flags &= ~(1 << shift);
|
||||
COGL_DEBUG_CLEAR_FLAG (shift);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -45,9 +45,7 @@ _cogl_uprof_init (void)
|
||||
_cogl_uprof_context = uprof_context_new ("Cogl");
|
||||
#define OPT(MASK_NAME, GROUP, NAME, NAME_FORMATTED, DESCRIPTION) \
|
||||
G_STMT_START { \
|
||||
int shift; \
|
||||
for (shift = 0; (COGL_DEBUG_ ## MASK_NAME >> shift) != 1; shift++) \
|
||||
; \
|
||||
int shift = COGL_DEBUG_ ## MASK_NAME; \
|
||||
uprof_context_add_boolean_option (_cogl_uprof_context, \
|
||||
GROUP, \
|
||||
NAME, \
|
||||
|
@ -454,7 +454,7 @@ _cogl_rectangle_map_add (CoglRectangleMap *map,
|
||||
map->space_remaining -= rectangle_size;
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DUMP_ATLAS_IMAGE))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DUMP_ATLAS_IMAGE)))
|
||||
{
|
||||
_cogl_rectangle_map_dump_image (map);
|
||||
/* Dumping the rectangle map is really slow so we might as well
|
||||
@ -545,7 +545,7 @@ _cogl_rectangle_map_remove (CoglRectangleMap *map,
|
||||
}
|
||||
|
||||
#ifdef COGL_ENABLE_DEBUG
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DUMP_ATLAS_IMAGE))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_DUMP_ATLAS_IMAGE)))
|
||||
{
|
||||
_cogl_rectangle_map_dump_image (map);
|
||||
/* Dumping the rectangle map is really slow so we might as well
|
||||
|
@ -275,7 +275,7 @@ _cogl_shader_set_source_with_boilerplate (GLuint shader_gl_handle,
|
||||
}
|
||||
count += count_in;
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_SHOW_SOURCE))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE)))
|
||||
{
|
||||
GString *buf = g_string_new (NULL);
|
||||
int i;
|
||||
@ -329,7 +329,7 @@ _cogl_shader_compile_real (CoglHandle handle,
|
||||
|
||||
GE (glBindProgram (GL_FRAGMENT_PROGRAM_ARB, shader->gl_handle));
|
||||
|
||||
if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_SHOW_SOURCE))
|
||||
if (G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_SHOW_SOURCE)))
|
||||
g_message ("user ARBfp program:\n%s", shader->source);
|
||||
|
||||
#ifdef COGL_GL_DEBUG
|
||||
|
Loading…
Reference in New Issue
Block a user