cogl: Add new option COGL_DEBUG=stencilling to disable optimizations

This means stencilling every clip stack entry even when stencilling could
be skipped. This visibly reveals some bugs in the stencilling logic.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1873>
This commit is contained in:
Daniel van Vugt 2021-05-20 18:21:04 +08:00
parent f390340da5
commit c3d64cc05b
4 changed files with 12 additions and 2 deletions

View File

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

View File

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

View File

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

View File

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