From 3fa91efea84c2c442fcc92e8ed0df711d7e67988 Mon Sep 17 00:00:00 2001 From: Neil Roberts Date: Wed, 10 Nov 2010 14:02:31 +0000 Subject: [PATCH] Add a COGL_DEBUG option to disable software clipping This adds a debug option called disable-software-clipping which causes the journal to always log the clip stack state rather than trying to manually clip rectangles. --- clutter/cogl/cogl/cogl-debug-options.h | 5 +++++ clutter/cogl/cogl/cogl-debug.c | 3 ++- clutter/cogl/cogl/cogl-debug.h | 3 ++- clutter/cogl/cogl/cogl-journal.c | 23 +++++++++++++---------- 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/clutter/cogl/cogl/cogl-debug-options.h b/clutter/cogl/cogl/cogl-debug-options.h index f1536020f..c93c301f3 100644 --- a/clutter/cogl/cogl/cogl-debug-options.h +++ b/clutter/cogl/cogl/cogl-debug-options.h @@ -143,6 +143,11 @@ OPT (DISABLE_NPOT_TEXTURES, "Disable non-power-of-two textures", "Makes Cogl think that the GL driver doesn't support NPOT textures " "so that it will create sliced textures or textures with waste instead.") +OPT (DISABLE_SOFTWARE_CLIP, + "Root Cause", + "disable-software-clip", + "Disable software clipping", + "Disables Cogl's attempts to clip some rectangles in software.") OPT (SHOW_SOURCE, "Cogl Tracing", "show-source", diff --git a/clutter/cogl/cogl/cogl-debug.c b/clutter/cogl/cogl/cogl-debug.c index 34351d9e9..5cfa8339e 100644 --- a/clutter/cogl/cogl/cogl-debug.c +++ b/clutter/cogl/cogl/cogl-debug.c @@ -72,7 +72,8 @@ static const GDebugKey cogl_behavioural_debug_keys[] = { { "disable-glsl", COGL_DEBUG_DISABLE_GLSL}, { "disable-blending", COGL_DEBUG_DISABLE_BLENDING}, { "disable-npot-textures", COGL_DEBUG_DISABLE_NPOT_TEXTURES}, - { "wireframe", COGL_DEBUG_WIREFRAME} + { "wireframe", COGL_DEBUG_WIREFRAME}, + { "disable-software-clip", COGL_DEBUG_DISABLE_SOFTWARE_CLIP} }; static const int n_cogl_behavioural_debug_keys = G_N_ELEMENTS (cogl_behavioural_debug_keys); diff --git a/clutter/cogl/cogl/cogl-debug.h b/clutter/cogl/cogl/cogl-debug.h index 6c9aee58f..4c49d7381 100644 --- a/clutter/cogl/cogl/cogl-debug.h +++ b/clutter/cogl/cogl/cogl-debug.h @@ -58,7 +58,8 @@ typedef enum { COGL_DEBUG_TEXTURE_PIXMAP = 1 << 25, COGL_DEBUG_BITMAP = 1 << 26, COGL_DEBUG_DISABLE_NPOT_TEXTURES = 1 << 27, - COGL_DEBUG_WIREFRAME = 1 << 28 + COGL_DEBUG_WIREFRAME = 1 << 28, + COGL_DEBUG_DISABLE_SOFTWARE_CLIP = 1 << 29 } CoglDebugFlags; #ifdef COGL_ENABLE_DEBUG diff --git a/clutter/cogl/cogl/cogl-journal.c b/clutter/cogl/cogl/cogl-journal.c index 210043b25..6a78d27bb 100644 --- a/clutter/cogl/cogl/cogl-journal.c +++ b/clutter/cogl/cogl/cogl-journal.c @@ -1155,16 +1155,19 @@ _cogl_journal_flush (void) state.modelview_stack = modelview_stack; state.projection_stack = _cogl_framebuffer_get_projection_stack (framebuffer); - /* 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 - separate walk of the journal because we can modify entries and - this may end up joining together clip stack batches in the next - iteration. */ - batch_and_call ((CoglJournalEntry *)ctx->journal->data, /* first entry */ - ctx->journal->len, /* max number of entries to consider */ - compare_entry_clip_stacks, - _cogl_journal_check_software_clip, /* callback */ - &state); /* data */ + if (G_UNLIKELY ((cogl_debug_flags & 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 + separate walk of the journal because we can modify entries and + this may end up joining together clip stack batches in the next + iteration. */ + batch_and_call ((CoglJournalEntry *)ctx->journal->data, /* first entry */ + ctx->journal->len, /* max number of entries to consider */ + compare_entry_clip_stacks, + _cogl_journal_check_software_clip, /* callback */ + &state); /* data */ + } /* We upload the vertices after the clip stack pass in case it modifies the entries */