[PATCH 09/10] presentation-shm: Allow setting of delay before surface.commit
Mario Kleiner
mario.kleiner.de at gmail.com
Sun Jun 21 12:25:16 PDT 2015
A new optional parameter "-d msecs" allows to specify a
delay before the surface attach/damage/commit to shift
the point in time when a surface update is committed.
This allows to test how different client timings interact
with the compositors repaint timing.
Suggested by Pekka Paalanen.
Signed-off-by: Mario Kleiner <mario.kleiner.de at gmail.com>
---
clients/presentation-shm.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/clients/presentation-shm.c b/clients/presentation-shm.c
index cf4517c..cafea40 100644
--- a/clients/presentation-shm.c
+++ b/clients/presentation-shm.c
@@ -101,6 +101,7 @@ struct window {
int num_buffers;
int next;
int refresh_nsec;
+ int commit_delay_msecs;
struct wl_callback *callback;
struct wl_list feedback_list;
@@ -201,19 +202,21 @@ static const struct wl_shell_surface_listener shell_surface_listener = {
static struct window *
create_window(struct display *display, int width, int height,
- enum run_mode mode)
+ enum run_mode mode, int commit_delay_msecs)
{
struct window *window;
char title[128];
int ret;
snprintf(title, sizeof(title),
- "presentation-shm: %s", run_mode_name[mode]);
+ "presentation-shm: %s [Delay %i msecs]", run_mode_name[mode],
+ commit_delay_msecs);
window = calloc(1, sizeof *window);
if (!window)
return NULL;
+ window->commit_delay_msecs = commit_delay_msecs;
window->mode = mode;
window->callback = NULL;
wl_list_init(&window->feedback_list);
@@ -490,6 +493,13 @@ window_create_feedback(struct window *window, uint32_t frame_stamp)
&feedback_listener, feedback);
feedback->frame_no = seq;
+
+ /* Delay by given msecs to test effects of compositor scheduling */
+ if (window->commit_delay_msecs > 0) {
+ struct timespec delay = { 0, window->commit_delay_msecs * 1e6 };
+ clock_nanosleep(window->display->clk_id, 0, &delay, NULL);
+ }
+
clock_gettime(window->display->clk_id, &feedback->commit);
feedback->frame_stamp = frame_stamp;
feedback->target = feedback->commit;
@@ -810,7 +820,8 @@ usage(const char *prog, int exit_code)
" -f\trun in feedback mode (default)\n"
" -i\trun in feedback-idle mode; sleep 1s between frames\n"
" -p\trun in low-latency presentation mode\n"
- "and 'options' may include\n",
+ "and 'options' may include\n"
+ " -d msecs\tdelay by given milliseconds before commit\n\n",
prog);
fprintf(stderr, "Printed timing statistics, depending on mode:\n"
@@ -835,6 +846,7 @@ main(int argc, char **argv)
int ret = 0;
enum run_mode mode = RUN_MODE_FEEDBACK;
int i;
+ int commit_delay_msecs = 0;
for (i = 1; i < argc; i++) {
if (strcmp("-f", argv[i]) == 0)
@@ -843,12 +855,16 @@ main(int argc, char **argv)
mode = RUN_MODE_FEEDBACK_IDLE;
else if (strcmp("-p", argv[i]) == 0)
mode = RUN_MODE_PRESENT;
+ else if ((strcmp("-d", argv[i]) == 0) && (i + 1 < argc)) {
+ i++;
+ commit_delay_msecs = atoi(argv[i]);
+ }
else
usage(argv[0], EXIT_FAILURE);
}
display = create_display();
- window = create_window(display, 250, 250, mode);
+ window = create_window(display, 250, 250, mode, commit_delay_msecs);
if (!window)
return 1;
--
1.9.1
More information about the wayland-devel
mailing list