From 5f6cb16e2b4d32a7d4bd2ee3381157b0bebba8d2 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 20 Jan 2011 14:41:51 +0000 Subject: [PATCH] debug: Adds a COGL_DEBUG=disable-fast-read-pixel option COGL_DEBUG=disable-fast-read-pixel can be used to disable the optimization for reading a single pixel colour back by looking at the geometry in the journal and not involving the GPU. With this disabled we will always flush the journal, rendering to the framebuffer and then use glReadPixels to get the result. --- cogl/cogl-debug-options.h | 7 ++++- cogl/cogl-debug.c | 3 +- cogl/cogl-debug.h | 61 ++++++++++++++++++++------------------- cogl/cogl-framebuffer.c | 3 ++ cogl/cogl-journal.c | 3 ++ 5 files changed, 45 insertions(+), 32 deletions(-) diff --git a/cogl/cogl-debug-options.h b/cogl/cogl-debug-options.h index 972c69cfe..578568353 100644 --- a/cogl/cogl-debug-options.h +++ b/cogl/cogl-debug-options.h @@ -168,4 +168,9 @@ OPT (DISABLE_BLENDING, "disable-program-caches", "Disable program caches", "Disable fallback caches for arbfp and glsl programs") - +OPT (DISABLE_FAST_READ_PIXEL, + "Root Cause", + "disable-fast-read-pixel", + "Disable read pixel optimization", + "Disable optimization for reading 1px for simple " + "scenes of opaque rectangles") diff --git a/cogl/cogl-debug.c b/cogl/cogl-debug.c index 5c2b5c2fe..77e43bf19 100644 --- a/cogl/cogl-debug.c +++ b/cogl/cogl-debug.c @@ -75,7 +75,8 @@ static const GDebugKey cogl_behavioural_debug_keys[] = { { "disable-npot-textures", COGL_DEBUG_DISABLE_NPOT_TEXTURES}, { "wireframe", COGL_DEBUG_WIREFRAME}, { "disable-software-clip", COGL_DEBUG_DISABLE_SOFTWARE_CLIP}, - { "disable-program-caches", COGL_DEBUG_DISABLE_PROGRAM_CACHES} + { "disable-program-caches", COGL_DEBUG_DISABLE_PROGRAM_CACHES}, + { "disable-fast-read-pixel", COGL_DEBUG_DISABLE_FAST_READ_PIXEL} }; static const int n_cogl_behavioural_debug_keys = G_N_ELEMENTS (cogl_behavioural_debug_keys); diff --git a/cogl/cogl-debug.h b/cogl/cogl-debug.h index 1a06bf734..51155edd8 100644 --- a/cogl/cogl-debug.h +++ b/cogl/cogl-debug.h @@ -31,36 +31,37 @@ G_BEGIN_DECLS typedef enum { - COGL_DEBUG_SLICING = 1 << 1, - COGL_DEBUG_OFFSCREEN = 1 << 2, - COGL_DEBUG_DRAW = 1 << 3, - COGL_DEBUG_PANGO = 1 << 4, - COGL_DEBUG_RECTANGLES = 1 << 5, - COGL_DEBUG_HANDLE = 1 << 6, - COGL_DEBUG_BLEND_STRINGS = 1 << 7, - COGL_DEBUG_DISABLE_BATCHING = 1 << 8, - COGL_DEBUG_DISABLE_VBOS = 1 << 9, - COGL_DEBUG_DISABLE_PBOS = 1 << 10, - COGL_DEBUG_JOURNAL = 1 << 11, - COGL_DEBUG_BATCHING = 1 << 12, - COGL_DEBUG_DISABLE_SOFTWARE_TRANSFORM = 1 << 13, - COGL_DEBUG_MATRICES = 1 << 14, - COGL_DEBUG_ATLAS = 1 << 15, - COGL_DEBUG_DUMP_ATLAS_IMAGE = 1 << 16, - COGL_DEBUG_DISABLE_ATLAS = 1 << 17, - COGL_DEBUG_OPENGL = 1 << 18, - COGL_DEBUG_DISABLE_TEXTURING = 1 << 19, - COGL_DEBUG_DISABLE_ARBFP = 1 << 20, - COGL_DEBUG_DISABLE_FIXED = 1 << 21, - COGL_DEBUG_DISABLE_GLSL = 1 << 22, - COGL_DEBUG_SHOW_SOURCE = 1 << 23, - COGL_DEBUG_DISABLE_BLENDING = 1 << 24, - 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_DISABLE_SOFTWARE_CLIP = 1 << 29, - COGL_DEBUG_DISABLE_PROGRAM_CACHES = 1 << 30 + 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 } CoglDebugFlags; #ifdef COGL_ENABLE_DEBUG diff --git a/cogl/cogl-framebuffer.c b/cogl/cogl-framebuffer.c index 1519d58f3..1a63cda84 100644 --- a/cogl/cogl-framebuffer.c +++ b/cogl/cogl-framebuffer.c @@ -1237,6 +1237,9 @@ _cogl_framebuffer_try_fast_read_pixel (CoglFramebuffer *framebuffer, { gboolean found_intersection; + if (G_UNLIKELY (cogl_debug_flags & COGL_DEBUG_DISABLE_FAST_READ_PIXEL)) + return FALSE; + if (source != COGL_READ_PIXELS_COLOR_BUFFER) return FALSE; diff --git a/cogl/cogl-journal.c b/cogl/cogl-journal.c index f0e8f3896..e9f3a4cef 100644 --- a/cogl/cogl-journal.c +++ b/cogl/cogl-journal.c @@ -1689,6 +1689,9 @@ try_checking_point_hits_entry_after_clipping (CoglJournalEntry *entry, ClipBounds clip_bounds; float poly[16]; + if (!can_software_clip) + return FALSE; + if (!can_software_clip_entry (entry, NULL, entry->clip_stack, &clip_bounds)) return FALSE;