diff --git a/cogl/cogl/cogl-debug-options.h b/cogl/cogl/cogl-debug-options.h index f6cda51a2..e6b1ca46d 100644 --- a/cogl/cogl/cogl-debug-options.h +++ b/cogl/cogl/cogl-debug-options.h @@ -189,3 +189,9 @@ OPT (TEXTURES, "textures", N_("Debug texture management"), N_("Logs information about texture management")) +OPT (STENCILLING, + N_("Root Cause"), + "stencilling", + N_("Stencil every clip entry"), + N_("Disables optimizations that usually avoid stencilling when it's not " + "needed. This exercises more of the stencilling logic than usual.")) diff --git a/cogl/cogl/cogl-debug.c b/cogl/cogl/cogl-debug.c index c4d648652..056d92ec3 100644 --- a/cogl/cogl/cogl-debug.c +++ b/cogl/cogl/cogl-debug.c @@ -85,6 +85,7 @@ static const GDebugKey cogl_behavioural_debug_keys[] = { { "disable-fast-read-pixel", COGL_DEBUG_DISABLE_FAST_READ_PIXEL}, { "sync-primitive", COGL_DEBUG_SYNC_PRIMITIVE }, { "sync-frame", COGL_DEBUG_SYNC_FRAME}, + { "stencilling", COGL_DEBUG_STENCILLING }, }; static const int n_cogl_behavioural_debug_keys = G_N_ELEMENTS (cogl_behavioural_debug_keys); diff --git a/cogl/cogl/cogl-debug.h b/cogl/cogl/cogl-debug.h index e202cc4a4..d818437f6 100644 --- a/cogl/cogl/cogl-debug.h +++ b/cogl/cogl/cogl-debug.h @@ -75,6 +75,7 @@ typedef enum COGL_DEBUG_SYNC_PRIMITIVE, COGL_DEBUG_SYNC_FRAME, COGL_DEBUG_TEXTURES, + COGL_DEBUG_STENCILLING, COGL_DEBUG_N_FLAGS } CoglDebugFlags; diff --git a/cogl/cogl/driver/gl/cogl-clip-stack-gl.c b/cogl/cogl/driver/gl/cogl-clip-stack-gl.c index 4975f34cf..bec4d9b45 100644 --- a/cogl/cogl/driver/gl/cogl-clip-stack-gl.c +++ b/cogl/cogl/driver/gl/cogl-clip-stack-gl.c @@ -500,7 +500,8 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack, /* We don't need to do anything extra if the clip for this rectangle was entirely described by its scissor bounds */ - if (!rect->can_be_scissor) + if (!rect->can_be_scissor || + G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_STENCILLING))) { COGL_NOTE (CLIPPING, "Adding stencil clip for rectangle"); @@ -522,7 +523,8 @@ _cogl_clip_stack_gl_flush (CoglClipStack *stack, /* If nrectangles <= 1, it can be fully represented with the * scissor clip. */ - if (cairo_region_num_rectangles (region->region) > 1) + if (cairo_region_num_rectangles (region->region) > 1 || + G_UNLIKELY (COGL_DEBUG_ENABLED (COGL_DEBUG_STENCILLING))) { COGL_NOTE (CLIPPING, "Adding stencil clip for region");