summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-01-28 10:03:54 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2013-01-28 10:06:47 +0000
commit3c18bae20ee2fea24d75f6986390ef8157d0207d (patch)
tree2c4994d8ce10a5f112ebd47d0e1655d7e63c94a6
parentd9d5adec256b3935e4f261d81c37c77a2649248b (diff)
perf; Do not allow the backends to optimize away the clear before sync
The importance of writing to the scratch surface before retrieving an image is that it makes that the write lands in the server queue, as well as the GetImage, in order to serialise the timer against all the operations. Reported-by: Siarhei Siamashka <siarhei.siamashka@gmail.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--perf/cairo-perf-trace.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/perf/cairo-perf-trace.c b/perf/cairo-perf-trace.c
index 4b8c85ea..f27f8e44 100644
--- a/perf/cairo-perf-trace.c
+++ b/perf/cairo-perf-trace.c
@@ -171,10 +171,12 @@ done:
}
static void
-clear_surface (cairo_surface_t *surface)
+fill_surface (cairo_surface_t *surface)
{
cairo_t *cr = cairo_create (surface);
- cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR);
+ /* This needs to be an operation that the backends can't optimise away */
+ cairo_set_source_rgba (cr, 0.5, 0.5, 0.5, 0.5);
+ cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
cairo_paint (cr);
cairo_destroy (cr);
}
@@ -714,6 +716,8 @@ cairo_perf_trace (cairo_perf_t *perf,
1, 1,
CAIRO_BOILERPLATE_MODE_PERF,
&args.closure);
+ fill_surface(args.surface); /* remove any clear flags */
+
if (perf->observe) {
cairo_surface_t *obs;
obs = cairo_surface_create_observer (args.surface,
@@ -768,7 +772,7 @@ cairo_perf_trace (cairo_perf_t *perf,
fill[i] = _cairo_time_from_s (1.e-9 * cairo_device_observer_fill_elapsed (observer));
glyphs[i] = _cairo_time_from_s (1.e-9 * cairo_device_observer_glyphs_elapsed (observer));
} else {
- clear_surface (args.surface); /* queue a write to the sync'ed surface */
+ fill_surface (args.surface); /* queue a write to the sync'ed surface */
cairo_perf_timer_stop ();
times[i] = cairo_perf_timer_elapsed ();
}