summaryrefslogtreecommitdiff
path: root/cogl/cogl-journal-private.h
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2011-01-12 22:12:41 +0000
committerRobert Bragg <robert@linux.intel.com>2011-01-21 16:18:11 +0000
commita8d6c3f686d5d59417bc5afe52ad2555331333e1 (patch)
treef04726679f9f3512f8bb943c2679dea1c8a2d19d /cogl/cogl-journal-private.h
parent3e42af2a006cefbcf7ce6d9e7315e8c204a2f896 (diff)
downloadcogl-a8d6c3f686d5d59417bc5afe52ad2555331333e1.tar.gz
cogl: Implements a software only read-pixel fast-path
This adds a transparent optimization to cogl_read_pixels for when a single pixel is being read back and it happens that all the geometry of the current frame is still available in the framebuffer's associated journal. The intention is to indirectly optimize Clutter's render based picking mechanism in such a way that the 99% of cases where scenes are comprised of trivial quad primitives that can easily be intersected we can avoid the latency of kicking a GPU render and blocking for the result when we know we can calculate the result manually on the CPU probably faster than we could even kick a render. A nice property of this solution is that it maintains all the flexibility of the render based picking provided by Clutter and it can gracefully fall back to GPU rendering if actors are drawn using anything more complex than a quad for their geometry. It seems worth noting that there is a limitation to the extensibility of this approach in that it can only optimize picking a against geometry that passes through Cogl's journal which isn't something Clutter directly controls. For now though this really doesn't matter since basically all apps should end up hitting this fast-path. The current idea to address this longer term would be a pick2 vfunc for ClutterActor that can support geometry and render based input regions of actors and move this optimization up into Clutter instead. Note: currently we don't have a primitive count threshold to consider that there could be scenes with enough geometry for us to compensate for the cost of kicking a render and determine a result more efficiently by utilizing the GPU. We don't currently expect this to be common though. Note: in the future it could still be interesting to revive something like the wip/async-pbo-picking branch to provide an asynchronous read-pixels based optimization for Clutter picking in cases where more complex input regions that necessitate rendering are in use or if we do add a threshold for rendering as mentioned above.
Diffstat (limited to 'cogl/cogl-journal-private.h')
-rw-r--r--cogl/cogl-journal-private.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/cogl/cogl-journal-private.h b/cogl/cogl-journal-private.h
index 754a2ecd..44a4af85 100644
--- a/cogl/cogl-journal-private.h
+++ b/cogl/cogl-journal-private.h
@@ -35,6 +35,8 @@ typedef struct _CoglJournal
GArray *vertices;
size_t needed_vbo_len;
+ int fast_read_pixel_count;
+
} CoglJournal;
/* To improve batching of geometry when submitting vertices to OpenGL we
@@ -69,4 +71,22 @@ void
_cogl_journal_flush (CoglJournal *journal,
CoglFramebuffer *framebuffer);
+void
+_cogl_journal_discard (CoglJournal *journal);
+
+gboolean
+_cogl_journal_all_entries_within_bounds (CoglJournal *journal,
+ float clip_x0,
+ float clip_y0,
+ float clip_x1,
+ float clip_y1);
+
+gboolean
+_cogl_journal_try_read_pixel (CoglJournal *journal,
+ int x,
+ int y,
+ CoglPixelFormat format,
+ guint8 *pixel,
+ gboolean *found_intersection);
+
#endif /* __COGL_JOURNAL_PRIVATE_H */